-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.dev.js
90 lines (86 loc) · 2.33 KB
/
webpack.dev.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* eslint-env node */
const path = require('path');
/* eslint-disable import/no-extraneous-dependencies */
const { merge } = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const common = require('./webpack.common');
module.exports = (env) => merge(common, {
mode: 'development',
devtool: 'inline-source-map',
devServer: {
client: {
webSocketURL: {
// Reload for the worker won't work when accessing devServer externally
hostname: 'localhost',
},
},
headers: (() => {
return env.e2e
? { 'Cache-Control': 'no-store' }
: {};
})(),
hot: true,
host: '0.0.0.0',
open: false,
static: [
{
directory: path.join(__dirname, 'packages/search/worker-dist'),
publicPath: '/',
},
{
directory: path.join(__dirname, 'test_files/1'),
publicPath: '/1',
watch: false,
},
{
directory: path.join(__dirname, 'test_files/2'),
publicPath: '/2',
watch: false,
},
{
directory: path.join(__dirname, 'test_files/3'),
publicPath: '/3',
watch: false,
},
{
directory: path.join(__dirname, 'e2e'),
publicPath: '/e2e',
watch: false,
},
{
directory: path.join(__dirname, 'packages/search-ui/public/static'),
publicPath: '/',
},
{
directory: path.join(__dirname, 'docs/book/html'),
publicPath: '/docs',
watch: false,
},
],
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
},
plugins: (() => {
const baseHtmlConfig = {
title: 'InfiSearch Dev Site',
scriptLoading: 'blocking',
favicon: path.join(__dirname, 'packages/search-ui/public/favicon.ico'),
template: './packages/search-ui/public/template.html',
};
const themes = ['basic', 'light', 'dark'];
const languages = ['ascii', 'ascii_stemmer', 'chinese'];
const plugins = [];
for (const theme of themes) {
for (const language of languages) {
plugins.push(new HtmlWebpackPlugin({
...baseHtmlConfig,
filename: `${theme}-theme_${language}-lang.html`,
chunks: [`search-ui-${language}`, `search-ui-${theme}`],
}));
}
}
return plugins;
})(),
});