This repository has been archived by the owner on May 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
88 lines (80 loc) · 1.74 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
require('dotenv').config({ silent: true });
const path = require('path');
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const AssetsPlugin = require('assets-webpack-plugin');
const parts = require('./webpack/parts');
const DEBUG = process.env.NODE_ENV !== 'production';
const genConfig = webpackMerge(
{
devtool: DEBUG ? 'eval' : false,
plugins: [
new webpack.DefinePlugin({
__DEV__: DEBUG,
}),
],
},
parts.setupJs(),
parts.setupCss(),
parts.setupFontGen(),
parts.setupFont(),
parts.setupImages(),
parts.setupJson(),
parts.setupI18n(),
!DEBUG && parts.setupProduction()
);
const config = webpackMerge(
{
entry: {
app: ['babel-polyfill', './app/client'],
},
output: {
path: path.join(__dirname, 'static'),
publicPath: '/static/',
filename: '[name].js?[hash]',
},
plugins: [
new webpack.DefinePlugin({
'process.env': JSON.stringify({
NODE_ENV: process.env.NODE_ENV,
}),
__CLIENT__: true,
}),
new AssetsPlugin({
path: path.join(__dirname, 'static'),
}),
],
},
genConfig
);
const serverConfig = webpackMerge(
{
entry: {
server: './app/server/server.js',
},
target: 'node',
node: {
__dirname: true,
__filename: true,
},
output: {
path: path.join(__dirname, 'static'),
filename: '[name].js',
publicPath: '/static/',
libraryTarget: 'commonjs2',
},
plugins: [
new webpack.DefinePlugin({
__CLIENT__: false,
}),
],
externals: [
/^[a-z\/\-0-9]+$/i,
],
},
genConfig
);
module.exports = [
DEBUG ? parts.setupHotReload(config) : config,
serverConfig,
];