-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
87 lines (85 loc) · 1.97 KB
/
webpack.config.babel.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
import webpack from 'webpack'
import CopyWebpackPlugin from 'copy-webpack-plugin'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import { VueLoaderPlugin } from 'vue-loader'
const mode = process.env.NODE_ENV || 'development'
export default {
mode,
target: 'web',
context: `${__dirname}/src`,
entry: {
background: './background',
options: './options',
popup: './popup'
},
output: {
path: `${__dirname}/app/`,
filename: '[name].js',
publicPath: '../'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.css$/,
use: ['vue-style-loader', 'css-loader']
},
{
test: /\.(jpg|gif|png|ico|woff|woff2|eot|ttf)$/,
loader: 'file-loader',
options: {
name: 'assets/[name].[ext]'
}
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(mode)
}
}),
new CopyWebpackPlugin([
{
from: 'manifest.json',
transform: function(content) {
return Buffer.from(
JSON.stringify({
...JSON.parse(content.toString()),
name: process.env.npm_package_productName,
description: process.env.npm_package_description,
version: process.env.npm_package_version
})
)
}
}
]),
new HtmlWebpackPlugin({
template: './assets/options.html',
filename: './assets/options.html',
chunks: ['options']
}),
new HtmlWebpackPlugin({
template: './assets/index.html',
filename: './assets/index.html',
chunks: ['index']
}),
new VueLoaderPlugin()
],
resolve: {
extensions: ['.js', '.json', '.vue'],
alias: {
'~~': `${__dirname}/`,
'~': `${__dirname}/src/`,
vue$: 'vue/dist/vue.esm.js'
}
}
}