forked from kriasoft/react-firebase-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
94 lines (88 loc) · 2.03 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
/**
* React Static Boilerplate
* Copyright (c) Konstantin Tarkus | MIT License
*/
import path from 'path';
import minimist from 'minimist';
import webpack from 'webpack';
import gutil from 'gulp-util';
import autoprefixer from 'autoprefixer-core';
import merge from 'lodash/object/merge';
const argv = minimist(process.argv.slice(2));
const DEBUG = !argv.release;
const VERBOSE = !!argv.verbose;
const AUTOPREFIXER_BROWSERS = [
'Android 2.3',
'Android >= 4',
'Chrome >= 20',
'Firefox >= 24',
'Explorer >= 8',
'iOS >= 6',
'Opera >= 12',
'Safari >= 6'
];
// Base configuration
const config = {
output: {
path: path.join(__dirname, 'build'),
publicPath: './',
sourcePrefix: ' '
},
cache: false,
debug: DEBUG,
stats: {
colors: gutil.colors.supportsColor,
reasons: DEBUG,
hash: VERBOSE,
version: VERBOSE,
timings: VERBOSE,
chunks: VERBOSE,
chunkModules: VERBOSE,
cached: VERBOSE,
cachedAssets: VERBOSE
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': DEBUG ? '"development"' : '"production"',
'__DEV__': DEBUG
})
],
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
}, {
test: /routes\.jsx?$/,
loader: './routes-loader.js'
}]
},
postcss: [autoprefixer(AUTOPREFIXER_BROWSERS)]
};
// Configuration for the client-side bundle
const appConfig = merge({}, config, {
entry: ['./scripts/app.js'].concat(global.hot ? 'webpack/hot/dev-server' : []),
output: {
filename: 'app.js'
}
});
// Configuration for server-side pre-rendering bundle
const pagesConfig = merge({}, config, {
entry: './scripts/pages.js',
output: {
filename: 'pages.js',
libraryTarget: 'commonjs2'
},
target: 'node',
externals: /^[a-z][a-z\.\-0-9]*$/,
node: {
console: false,
global: false,
process: false,
Buffer: false,
__filename: false,
__dirname: false
}
});
export default [appConfig, pagesConfig];