Skip to content

Commit

Permalink
Use loop to create HtmlWebpackPlugins
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmooney committed Nov 5, 2024
1 parent 88b6a09 commit 75304ad
Showing 1 changed file with 21 additions and 72 deletions.
93 changes: 21 additions & 72 deletions app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,26 @@ if (process.argv.includes('--analyze')) {
extras.push(new BundleAnalyzerPlugin());
}

const htmlPlugins = [];
['consoles', 'edit', 'error', 'notebooks', 'terminals', 'tree'].forEach(
(name) => {
htmlPlugins.push(
new HtmlWebpackPlugin({
chunksSortMode: 'none',
template: path.join(
path.resolve('./templates'),
`${name}_template.html`
),
title: name,
filename: path.join(
path.resolve(__dirname, '..', 'notebook/templates'),
`${name}.html`
),
})
);
}
);

module.exports = [
merge(baseConfig, {
mode: 'development',
Expand Down Expand Up @@ -233,78 +253,7 @@ module.exports = [
fallback: { util: false },
},
plugins: [
new HtmlWebpackPlugin({
chunksSortMode: 'none',
template: path.join(
path.resolve(__dirname, '..', 'notebook/templates'),
'consoles_template.html'
),
title: data.jupyterlab.name,
filename: path.join(
path.resolve(__dirname, '..', 'notebook/templates'),
'consoles.html'
),
}),
new HtmlWebpackPlugin({
chunksSortMode: 'none',
template: path.join(
path.resolve(__dirname, '..', 'notebook/templates'),
'edit_template.html'
),
title: data.jupyterlab.name,
filename: path.join(
path.resolve(__dirname, '..', 'notebook/templates'),
'edit.html'
),
}),
new HtmlWebpackPlugin({
chunksSortMode: 'none',
template: path.join(
path.resolve(__dirname, '..', 'notebook/templates'),
'error_template.html'
),
title: data.jupyterlab.name,
filename: path.join(
path.resolve(__dirname, '..', 'notebook/templates'),
'error.html'
),
}),
new HtmlWebpackPlugin({
chunksSortMode: 'none',
template: path.join(
path.resolve(__dirname, '..', 'notebook/templates'),
'notebooks_template.html'
),
title: data.jupyterlab.name,
filename: path.join(
path.resolve(__dirname, '..', 'notebook/templates'),
'notebooks.html'
),
}),
new HtmlWebpackPlugin({
chunksSortMode: 'none',
template: path.join(
path.resolve(__dirname, '..', 'notebook/templates'),
'terminals_template.html'
),
title: data.jupyterlab.name,
filename: path.join(
path.resolve(__dirname, '..', 'notebook/templates'),
'terminals.html'
),
}),
new HtmlWebpackPlugin({
chunksSortMode: 'none',
template: path.join(
path.resolve(__dirname, '..', 'notebook/templates'),
'tree_template.html'
),
title: data.jupyterlab.name,
filename: path.join(
path.resolve(__dirname, '..', 'notebook/templates'),
'tree.html'
),
}),
...htmlPlugins,
new WPPlugin.JSONLicenseWebpackPlugin({
excludedPackageTest: (packageName) =>
packageName === '@jupyter-notebook/app',
Expand Down

0 comments on commit 75304ad

Please sign in to comment.