forked from yiwenl/Sketches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
85 lines (81 loc) · 2.28 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
/* eslint comma-dangle: 0 */
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const prod = process.env.NODE_ENV === 'production';
const isDevelopment = process.env.NODE_ENV === 'development';
const ip = require('ip');
const serverIp = ip.address();
function getOutput() {
if(prod) {
return path.resolve(__dirname, "assets/" )
} else {
return path.resolve(__dirname, "assets/" )
}
}
module.exports = {
hotPort: 8080,
cache: isDevelopment,
debug: isDevelopment,
entry: {
app: ['./src/js/app.js']
},
stats: {
cached: false,
cachedAssets: false,
chunkModules: false,
chunks: false,
colors: true,
errorDetails: true,
hash: false,
progress: true,
reasons: false,
timings: true,
version: false
},
output: {
path: getOutput(),
filename:'js/bundle.js',
publicPath: isDevelopment ? `http://${serverIp}:8080/assets/` : ''
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
query: {
plugins: ['transform-runtime', 'add-module-exports'],
presets: ['es2015', 'stage-1']
}
},
{
test: /\.css$/,
loader: 'style!css'
},
{
test: /\.scss$/,
loader: prod ?
ExtractTextPlugin.extract("style-loader", `css-loader!autoprefixer-loader?browsers=last 3 version!sass-loader?includePaths[]=""`) :
`style!css!autoprefixer?browsers=last 3 version!sass?includePaths[]=""`
},
{ test: /\.(glsl|frag|vert)$/, loader: 'raw', exclude: /node_modules/ },
{ test: /\.(glsl|frag|vert)$/, loader: 'glslify', exclude: /node_modules/ }
]
},
plugins: prod ? [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({'process.env.NODE_ENV': '"production"'}),
new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true,
warnings: false
}
}),
new ExtractTextPlugin('css/main.css')
] : [
new webpack.DefinePlugin({'process.env.NODE_ENV': '"development"'}),
new webpack.optimize.OccurenceOrderPlugin()
]
};