Skip to content

Commit 75304ad

Browse files
author
Greg
committed
Use loop to create HtmlWebpackPlugins
1 parent 88b6a09 commit 75304ad

File tree

1 file changed

+21
-72
lines changed

1 file changed

+21
-72
lines changed

app/webpack.config.js

+21-72
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,26 @@ if (process.argv.includes('--analyze')) {
205205
extras.push(new BundleAnalyzerPlugin());
206206
}
207207

208+
const htmlPlugins = [];
209+
['consoles', 'edit', 'error', 'notebooks', 'terminals', 'tree'].forEach(
210+
(name) => {
211+
htmlPlugins.push(
212+
new HtmlWebpackPlugin({
213+
chunksSortMode: 'none',
214+
template: path.join(
215+
path.resolve('./templates'),
216+
`${name}_template.html`
217+
),
218+
title: name,
219+
filename: path.join(
220+
path.resolve(__dirname, '..', 'notebook/templates'),
221+
`${name}.html`
222+
),
223+
})
224+
);
225+
}
226+
);
227+
208228
module.exports = [
209229
merge(baseConfig, {
210230
mode: 'development',
@@ -233,78 +253,7 @@ module.exports = [
233253
fallback: { util: false },
234254
},
235255
plugins: [
236-
new HtmlWebpackPlugin({
237-
chunksSortMode: 'none',
238-
template: path.join(
239-
path.resolve(__dirname, '..', 'notebook/templates'),
240-
'consoles_template.html'
241-
),
242-
title: data.jupyterlab.name,
243-
filename: path.join(
244-
path.resolve(__dirname, '..', 'notebook/templates'),
245-
'consoles.html'
246-
),
247-
}),
248-
new HtmlWebpackPlugin({
249-
chunksSortMode: 'none',
250-
template: path.join(
251-
path.resolve(__dirname, '..', 'notebook/templates'),
252-
'edit_template.html'
253-
),
254-
title: data.jupyterlab.name,
255-
filename: path.join(
256-
path.resolve(__dirname, '..', 'notebook/templates'),
257-
'edit.html'
258-
),
259-
}),
260-
new HtmlWebpackPlugin({
261-
chunksSortMode: 'none',
262-
template: path.join(
263-
path.resolve(__dirname, '..', 'notebook/templates'),
264-
'error_template.html'
265-
),
266-
title: data.jupyterlab.name,
267-
filename: path.join(
268-
path.resolve(__dirname, '..', 'notebook/templates'),
269-
'error.html'
270-
),
271-
}),
272-
new HtmlWebpackPlugin({
273-
chunksSortMode: 'none',
274-
template: path.join(
275-
path.resolve(__dirname, '..', 'notebook/templates'),
276-
'notebooks_template.html'
277-
),
278-
title: data.jupyterlab.name,
279-
filename: path.join(
280-
path.resolve(__dirname, '..', 'notebook/templates'),
281-
'notebooks.html'
282-
),
283-
}),
284-
new HtmlWebpackPlugin({
285-
chunksSortMode: 'none',
286-
template: path.join(
287-
path.resolve(__dirname, '..', 'notebook/templates'),
288-
'terminals_template.html'
289-
),
290-
title: data.jupyterlab.name,
291-
filename: path.join(
292-
path.resolve(__dirname, '..', 'notebook/templates'),
293-
'terminals.html'
294-
),
295-
}),
296-
new HtmlWebpackPlugin({
297-
chunksSortMode: 'none',
298-
template: path.join(
299-
path.resolve(__dirname, '..', 'notebook/templates'),
300-
'tree_template.html'
301-
),
302-
title: data.jupyterlab.name,
303-
filename: path.join(
304-
path.resolve(__dirname, '..', 'notebook/templates'),
305-
'tree.html'
306-
),
307-
}),
256+
...htmlPlugins,
308257
new WPPlugin.JSONLicenseWebpackPlugin({
309258
excludedPackageTest: (packageName) =>
310259
packageName === '@jupyter-notebook/app',

0 commit comments

Comments
 (0)