-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
84 lines (78 loc) · 1.89 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
const path = require('path')
const webpack = require('webpack')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const vueUtils = require('./vue-utils')
const cssLoaders = vueUtils.cssLoaders()
const styleLoaders = vueUtils.styleLoaders()
console.log('env', process.env.NODE_ENV)
const outputDir = path.resolve(__dirname, './dist/main/build')
module.exports = {
entry: {
content_script: './main/src/content_script/main.js'
},
output: {
path: outputDir,
filename: '[name].js'
},
module: {
rules: ([
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: cssLoaders
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|eot|svg|ttf|woff)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
},
{
test: /\.(woff2)$/,
loader: 'url-loader',
options: {
limit: 50000,
}
},
].concat(styleLoaders))
},
performance: {
hints: false
},
devServer: {
contentBase: outputDir,
port: 9090,
},
devtool: '#eval-source-map',
// devtool: '#source-map',
mode: process.env.NODE_ENV,
}
if (process.env.NODE_ENV === 'development') {
module.exports.plugins = (module.exports.plugins || []).concat([
new HtmlWebpackPlugin()
])
} else if (process.env.NODE_ENV === 'production') {
module.exports.devtool = void 0
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.LoaderOptionsPlugin({
minimize: true
}),
new CopyWebpackPlugin([
{
from: 'main',
to: path.resolve(__dirname, 'dist/main'),
ignore: [ 'src/**/*' ]
}
])
])
}