-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
119 lines (111 loc) · 2.78 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
const webpack = require('webpack');
const ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
const OptimizeCssAssetsWebpackPlugin = require('optimize-css-assets-webpack-plugin');
const path = require('path');
const fs = require('fs');
var uglifyJsPlugin = process.env.PROD == 1? [
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
output: {
comments: false
},
compressor: {
warnings: false
}
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})
] : [];
var uglifyCssPlugin = process.env.PROD == 1? [ new OptimizeCssAssetsWebpackPlugin() ] : []
var node_modules = {};
fs.readdirSync('node_modules')
.filter(function(x) {
return ['.bin'].indexOf(x) === -1;
})
.forEach(function(mod) {
node_modules[mod] = 'commonjs ' + mod;
});
module.exports = [
{
externals: node_modules,
node: {
__filename: true,
__dirname: true
},
target: 'node',
name: 'react-stuff',
entry: path.join(__dirname, '/resources/scripts/entry.js'),
output: {
filename: 'app.js',
path: path.join(__dirname, '/app/scripts')
},
module: {
loaders: [
{
test: /\.js/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['react', 'es2017', 'es2016', 'es2015'],
plugins: ['babel-plugin-transform-object-rest-spread', 'babel-plugin-transform-class-properties']
}
}
]
},
plugins: uglifyJsPlugin
},
{
externals: node_modules,
node: {
__filename: true,
__dirname: true
},
target: 'node',
name: 'electron main',
entry: path.join(__dirname, '/main_process/entry.js'),
output: {
pathinfo: true,
filename: 'main.js',
path: path.join(__dirname, '/app/scripts')
},
module: {
loaders: [
{
test: /\.js/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['react', 'es2017', 'es2016', 'es2015'],
plugins: ['babel-plugin-transform-object-rest-spread', 'babel-plugin-transform-class-properties']
}
}
]
},
plugins: uglifyJsPlugin
},
{
name: 'stylesheets',
entry: path.join(__dirname, '/resources/styles/entry.sass'),
output: {
filename: 'app.css',
path: path.join(__dirname, '/app/styles')
},
module: {
loaders: [
{
test: /\.sass/,
loader: ExtractTextWebpackPlugin.extract({
use: 'css-loader?url=false!sass-loader?url=false',
fallback: 'style-loader'
})
}
]
},
plugins: [
new ExtractTextWebpackPlugin('app.css')
].concat(uglifyCssPlugin)
}
];