-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.production.js
98 lines (95 loc) · 2.04 KB
/
webpack.config.production.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
import path from 'path'
import fs from 'fs'
import webpack from 'webpack'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import postcssNested from 'postcss-nested'
import postcssCssnext from 'postcss-cssnext'
const nodeModules = {}
fs.readdirSync('node_modules').
filter(x => ['.bin'].indexOf(x) === -1).
forEach(mod => {
nodeModules[mod] = `commonjs ${mod}`
})
exports.backend = {
target: 'node',
entry: [
'babel-polyfill',
'./server/server.js',
],
output: {
path: path.join(__dirname, 'build'),
filename: 'backend.js',
},
resolve: {
extensions: ['', '.jsx', '.js', '.css'],
},
node: {
__filename: true,
__dirname: false,
},
module: {
loaders: [{
test: /(\.js|\.jsx)$/,
exclude: /(node_modules)/,
loader: 'babel',
}, {
test: /\.(png|jpg|jpeg)$/,
loader: 'url?limit=3072',
}],
},
plugins: [
new webpack.BannerPlugin('require("source-map-support").install();', {
raw: true,
entryOnly: false,
}),
new webpack.NormalModuleReplacementPlugin(/\.css$/,
path.join(__dirname, 'node_modules/node-noop/index.js')),
],
externals: nodeModules,
devtool: 'source-map',
}
exports.frontend = {
entry: [
'babel-polyfill',
'./client/index.jsx',
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'frontend.min.js',
publicPath: '/',
},
resolve: {
extensions: ['', '.jsx', '.js', '.css'],
},
module: {
loaders: [{
test: /(\.js|\.jsx)$/,
exclude: /(node_modules)/,
loader: 'babel',
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css!postcss'),
}, {
test: /\.(png|jpg|jpeg)$/,
loader: 'url?limit=3072',
}],
},
externals: {
falcor: 'falcor',
'falcor-http-datasource': 'falcor.HttpDataSource',
},
postcss: [postcssNested, postcssCssnext],
plugins: [
new ExtractTextPlugin('main.min.css'),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compressor: {
screw_ie8: true,
warnings: false,
},
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
],
}