-
Notifications
You must be signed in to change notification settings - Fork 79
/
webpack.config.js
executable file
·68 lines (65 loc) · 1.81 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
const webpack = require('webpack')
const path = require('path')
const WriteFilePlugin = require('write-file-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { NODE_ENV, TARGET } = require('./utils/env')
const copyWebpackPlugins = [
{ from: './src/icons' },
{ from: './src/pages/options.css' }
]
// Try the environment variable, otherwise use root
const ASSET_PATH = process.env.ASSET_PATH || '/'
module.exports = {
mode: NODE_ENV,
entry: {
better_github_prs: path.join(__dirname, 'src', 'js', 'index.jsx'),
background: path.join(__dirname, 'src', 'js', 'background.js'),
options: path.join(__dirname, 'src', 'js', 'options.jsx')
},
output: {
path: path.join(__dirname, 'build', TARGET, NODE_ENV),
publicPath: ASSET_PATH,
filename: '[name].js'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(woff2)$/,
use: ['file-loader?name=/fonts/[name].[ext]']
}
]
},
resolve: {
extensions: ['.js', '.jsx', '.css'],
symlinks: false,
modules: [path.resolve('node_modules')]
},
plugins: [
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
'process.env.TARGET': JSON.stringify(TARGET)
}),
new CopyWebpackPlugin({ patterns: copyWebpackPlugins }),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src', 'pages', 'options.html'),
filename: 'options.html',
chunks: ['options']
}),
new WriteFilePlugin({
log: false
})
]
}