/
webpack.config.js
46 lines (40 loc) · 1.26 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
const { CleanWebpackPlugin } = require('clean-webpack-plugin'),
CopyWebpackPlugin = require('copy-webpack-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
WriteFilePlugin = require('write-file-webpack-plugin'),
yaml = require('js-yaml'),
path = require('path')
const mode = process.env.NODE_ENV || 'development'
const configs = {
mode,
entry: { content: './src/content.js' },
plugins: [
new CleanWebpackPlugin(),
new CopyWebpackPlugin([
{ from: 'src/background.js' },
{
from: 'src/manifest.yml',
to: 'manifest.json',
transform: function(content) {
return Buffer.from(
JSON.stringify({
version: process.env.npm_package_version,
...yaml.safeLoad(content),
}),
)
},
},
{
from: 'assets/*',
flatten: true,
},
]),
new WriteFilePlugin(),
],
}
if (mode == 'development'){
configs.devtool = 'cheap-module-eval-source-map'
} else {
configs.devtool = 'nosources-source-map'
}
module.exports = configs