-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
65 lines (63 loc) · 2.45 KB
/
webpack.config.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 HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const { default: Aurelia } = require('aurelia');
const cssLoader = 'css-loader';
module.exports = function (env, { analyze }) {
const production = env === 'production' || process.env.NODE_ENV === 'production';
return {
mode: production ? 'production' : 'development',
devtool: !production ? 'inline-source-map' : false,
entry: {
entry: './src/main.ts',
detector: './src/detector/detector.ts',
background: './src/background/background.ts',
['contentscript']: './src/contentscript/contentscript.ts',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'build/[name].js',
libraryTarget: 'var',
library: '[name]'
},
resolve: {
extensions: ['.ts', '.js'],
modules: [path.resolve(__dirname, 'src'), 'node_modules']
},
devServer: {
historyApiFallback: true,
open: !process.env.CI,
port: 9002,
lazy: false
},
module: {
rules: [
{ test: /\.(png|gif|jpg|cur)$/i, loader: 'url-loader', options: { limit: 8192 } },
{ test: /\.woff2(\?v=[0-9]\.[0-9]\.[0-9])?$/i, loader: 'url-loader', options: { limit: 10000, mimetype: 'application/font-woff2' } },
{ test: /\.woff(\?v=[0-9]\.[0-9]\.[0-9])?$/i, loader: 'url-loader', options: { limit: 10000, mimetype: 'application/font-woff' } },
{ test: /\.(ttf|eot|svg|otf)(\?v=[0-9]\.[0-9]\.[0-9])?$/i, loader: 'file-loader' },
{ test: /\.css$/i, use: ['style-loader', cssLoader] },
{ test: /\.ts$/i, use: ['ts-loader', '@aurelia/webpack-loader'], exclude: /node_modules/ },
{ test: /\.html$/i, use: '@aurelia/webpack-loader', exclude: /node_modules/ }
]
},
optimization: {
minimize: false
},
plugins: [
new HtmlWebpackPlugin({ cache: false, template: 'index-v2.html', filename: 'index-v2.html', chunks: ['entry'], inject: true }),
analyze && new BundleAnalyzerPlugin(),
new CopyPlugin({
patterns: [
{ from: 'src/popups', to: 'popups' },
{ from: 'images', to: 'images' },
{ from: 'scripts', to: 'build' },
{ from: 'index-v1.html', to: '' },
{ from: 'manifest.json', to: '' },
{ from: 'src/devtools', to: '' },
],
}),
].filter(p => p)
}
}