forked from dessant/buster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·95 lines (91 loc) · 2.21 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
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
91
92
93
94
95
const path = require('path');
const webpack = require('webpack');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const targetEnv = process.env.TARGET_ENV || 'firefox';
const isProduction = process.env.NODE_ENV === 'production';
let plugins = [
new webpack.DefinePlugin({
'process.env': {
TARGET_ENV: JSON.stringify(targetEnv)
},
global: {}
}),
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: '[name]/style.css'
}),
isProduction ? new LodashModuleReplacementPlugin({shorthands: true}) : null
];
plugins = plugins.filter(Boolean);
module.exports = {
mode: isProduction ? 'production' : 'development',
entry: {
background: './src/background/main.js',
options: './src/options/main.js',
contribute: './src/contribute/main.js',
solve: './src/solve/main.js',
setup: './src/setup/main.js'
},
output: {
path: path.resolve(__dirname, 'dist', targetEnv, 'src'),
chunkFilename: '[name]/script.js'
},
optimization: {
runtimeChunk: {
name: 'manifest'
},
splitChunks: {
cacheGroups: {
default: false,
commonsUi: {
name: 'commons-ui',
chunks: chunk => {
return ['options', 'contribute', 'setup'].includes(chunk.name);
},
minChunks: 2
}
}
}
},
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader'
},
{
test: /\.vue$/,
use: [
{
loader: 'vue-loader',
options: {
transformAssetUrls: {img: ''}
}
}
]
},
{
test: /\.(c|sc|sa)ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
{
loader: 'sass-loader',
options: {
includePaths: ['node_modules']
}
}
]
}
]
},
resolve: {
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
extensions: ['.js', '.json', '.css', '.scss', '.vue']
},
devtool: false,
plugins
};