forked from abeade/browser-websocket-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
83 lines (81 loc) · 2.04 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
const merge = require('webpack-merge')
const webpack = require('webpack')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const GenerateJsonPlugin = require('generate-json-webpack-plugin')
const path = require('path')
const ROOT = path.resolve(__dirname)
const root = path.join.bind(path, ROOT)
const version = require('./src/manifest/common.json').version
module.exports = function (env) {
const [mode, platform] = env.split(':')
let buildPath = root('build/' + mode + '/' + platform)
// noinspection WebpackConfigHighlighting
return {
mode: mode,
entry: {
'index': './src/main/index.js',
'background': './src/main/background.js',
'styles': './src/main/styles/custom.scss'
},
output: {
path: buildPath,
filename: '[name].js',
sourceMapFilename: '[name].js.map'
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.js$/,
exclude: [
/\.spec\.js$/
],
loader: 'babel-loader'
}, {
test: /\.(scss)$/,
use: [{
loader: 'style-loader'
}, {
loader: 'css-loader'
}, {
loader: 'postcss-loader',
options: {
plugins: function () {
return [
require('precss'),
require('autoprefixer')
]
}
}
}, {
loader: 'sass-loader'
}]
}
]
},
resolve: {
modules: [
root('src'),
root('node_modules')
]
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}),
new CopyWebpackPlugin([
{
from: 'icons', to: buildPath
}, {
from: 'src/main/index.html', to: buildPath
}
]),
new GenerateJsonPlugin('manifest.json', merge(
require('./src/manifest/common.json'),
require(`./src/manifest/${platform}.json`),
{version}
), null, 2)
]
}
}