forked from refined-bitbucket/refined-bitbucket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
76 lines (74 loc) · 2.29 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
'use strict';
const path = require('path');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
devtool: 'source-map',
entry: {
main: './src/main',
options: './src/options',
background: './src/background'
},
plugins: [
new webpack.DefinePlugin({
process: {}
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new CopyWebpackPlugin([
{
from: '*',
context: 'src',
ignore: '*.js'
},
{
from: 'src/vendor/prism.js'
}
])
],
output: {
path: path.join(__dirname, 'extension'),
filename: '[name].js'
},
module: {
rules: [
{
oneOf: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
}
]
}
};
if (process.env.NODE_ENV === 'production') {
module.exports.plugins.push(
new UglifyJSPlugin({
sourceMap: false,
uglifyOptions: {
mangle: true,
output: {
beautify: false
},
compress: {
// https://github.com/refined-bitbucket/refined-bitbucket/issues/115
// https://github.com/refined-bitbucket/refined-bitbucket/pull/116
// The default value of this option was producing a bundle
// with broken code due to a constant variable reassignment
// that ended up causing a TypeError at runtime.
// See the issue and the pull request for more details.
// (default: true) -- Improve optimization on variables assigned with and used as constant values.
// eslint-disable-next-line camelcase
reduce_vars: false
}
}
})
);
}