This repository has been archived by the owner on Oct 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
82 lines (76 loc) · 1.89 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
var path = require('path')
var webpack = require('webpack')
var CopyWebpackPlugin = require('copy-webpack-plugin')
var publicPath = 'http://localhost:4001/'
var env = process.env.MIX_ENV || 'dev'
var prod = env === 'prod'
var dev = env === 'dev'
var nodeEnv = process.env.NODE_ENV = ({
dev: 'development',
prod: 'production'
})[env] || env
var plugins = [
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env': {NODE_ENV: JSON.stringify(nodeEnv)},
__PROD: prod,
__DEV: dev
}),
new webpack.optimize.OccurenceOrderPlugin(),
new CopyWebpackPlugin([
{ from: 'web/static/assets', to: '.' }
])
]
if (dev) {
plugins.push(new webpack.HotModuleReplacementPlugin())
} else if (prod) {
plugins.push(new webpack.optimize.UglifyJsPlugin({
compressor: { warnings: false }
}))
}
var hot = 'webpack-hot-middleware/client?path=' +
publicPath + '__webpack_hmr'
var entry = {
index: './web/static/js/index.js',
admin: './web/static/js/admin.js'
}
module.exports = {
devtool: prod ? null : 'eval-source-map',
entry: Object.keys(entry).reduce(function (entries, key) {
entries[key] = prod
? entry[key]
: [entry[key], hot]
return entries
}, {}),
output: {
path: path.resolve(__dirname, 'priv/static'),
filename: '[name].bundle.js',
publicPath: publicPath
},
plugins: plugins,
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel',
exclude: /node_modules/
}, {
test: /\.css$/,
loader: 'style!css!postcss'
}
]
},
postcss: function () {
return [
require('postcss-import')({
addDependencyTo: webpack
}),
require('postcss-nested')(),
require('postcss-sassy-mixins')(),
require('postcss-simple-vars')(),
require('postcss-cssnext')(),
require('postcss-browser-reporter')(),
require('postcss-reporter')()
]
}
}