-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
93 lines (85 loc) · 2.15 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
var path = require('path')
var webpack = require('webpack')
var CopyWebpackPlugin = require('copy-webpack-plugin')
if (!process.env.BUILD_ENV) {
process.env.BUILD_ENV = 'development'
}
var ENV = process.env.BUILD_ENV
console.log('webpack run with BUILD_FIREBASE_HOST', process.env.BUILD_FIREBASE_HOST)
if (!process.env.BUILD_FIREBASE_HOST) { console.log('Need BUILD_FIREBASE_HOST env var'); process.exit()}
var srcPath = path.join(__dirname, '/src')
var imagePath = path.join(__dirname, '/images')
console.log(ENV);
var basePlugins = [
new CopyWebpackPlugin([
{from: './200.html'},
]),
new webpack.DefinePlugin({
__FIREBASE_HOST__: JSON.stringify(process.env.BUILD_FIREBASE_HOST.trim()),
}),
new webpack.EnvironmentPlugin([
'BUILD_ENV',
]),
]
var prodPlugins = [
new webpack.optimize.UglifyJsPlugin({minimize: true}),
]
var plugins = basePlugins.concat(ENV == 'production' ? prodPlugins : [])
module.exports = {
entry: ['./src/main'],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
},
devServer: {
hot: true,
inline: true,
historyApiFallback: true,
},
module: {
loaders: [
{
test: /\.js$/,
loaders: ['babel', 'eslint'],
include: __dirname,
exclude: /node_modules/,
},
{
test: /\.css$/,
loader: 'style-loader!css-loader?sourceMap',
include: __dirname,
},
{
test: /\.scss/,
loaders: [
'style-loader',
'css-loader',
'postcss-loader',
'sass-loader?outputStyle=expanded',
],
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false',
],
},
],
},
externals: {
Bugsnag: 'Bugsnag',
},
resolve: {
alias: {
drivers: srcPath + '/drivers',
components: srcPath + '/components',
helpers: srcPath + '/helpers',
root: srcPath + '/root',
images: imagePath,
util: srcPath + '/util',
remote: srcPath + '/remote',
},
},
plugins: plugins,
}