-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
93 lines (87 loc) · 2.3 KB
/
Copy pathwebpack.config.js
File metadata and controls
93 lines (87 loc) · 2.3 KB
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
'use strict' // eslint-disable-line
const path = require('path')
const webpack = require('webpack')
const packge = require('./package.json')
// https://github.com/halt-hammerzeit/webpack-isomorphic-tools
const WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin')
const webpackIsomorphicToolsPlugin = new WebpackIsomorphicToolsPlugin(
require('./webpack-isomorphic-tools')
)
const configurations = [
// Minified version
{
entry: './src/browser.jsx',
output: {
path: path.join(__dirname, '/public/scripts'),
filename: 'main.min.js',
},
resolve: {
extensions: ['', '.js', '.jsx'],
},
module: {
loaders: [
{ test: /\.css$/, loader: 'style!css' },
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel', // 'babel-loader' is also a legal name to reference
},
],
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"',
version: `'${packge.version}'`,
},
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
}),
],
},
// Development version
{
entry: [
// 'webpack-hot-middleware/client?path=http://localhost:5000/scripts/__webpack_hmr',
'./src/browser.jsx',
],
output: {
path: path.join(__dirname, '/public/scripts'),
filename: 'main.js',
sourceMapFilename: 'main.map',
publicPath: '/scripts/',
},
resolve: {
extensions: ['', '.js', '.jsx'],
},
module: {
loaders: [
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.jsx?$/, exclude: /node_modules/,
loaders: ['babel'],
},
],
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"development"',
version: `'${packge.version}'`,
},
}),
// new webpack.HotModuleReplacementPlugin(),
],
devtool: 'eval',
},
]
module.exports = configurations.filter((conf, i) => {
if (i === 0) {
return process.env.PROD !== '0'
} else if (i === 1) {
return process.env.DEV !== '0'
}
return false
})