-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
65 lines (63 loc) · 1.67 KB
/
webpack.common.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
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const webpack = require('webpack');
const getHtmlPlugins = (filenames) =>
filenames.map((file) => new HtmlWebpackPlugin({
filename: `${file}.html`,
chunks: [file],
cache: false
}));
module.exports = {
entry: {
background: path.resolve('src/scripts/background/index.ts'),
contentscript: path.resolve('src/scripts/content/index.tsx'),
injectedscript: path.resolve('src/scripts/injected/index.ts'),
options: path.resolve('src/pages/options/index.tsx'),
panel: path.resolve('src/pages/panel/index.tsx'),
popup: path.resolve('src/pages/popup/index.tsx'),
},
module: {
rules: [
{
use: 'ts-loader',
test: /\.(tsx|ts)?$/,
exclude: /node_modules/,
},
{
use: ['style-loader', 'css-loader'],
test: /\.css?$/,
exclude: /node_modules/,
},
],
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
new CleanWebpackPlugin({
cleanStaleWebpackAssets: false,
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve('src/static'),
to: path.resolve('dist'),
},
],
}),
...getHtmlPlugins(['devtools', 'newtab', 'options', 'panel', 'popup'])
],
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
output: {
filename: '[name].js',
path: path.resolve('dist'),
},
optimization: {
// This is to disable chunks completely
splitChunks: false
},
};