-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
114 lines (106 loc) · 3.29 KB
/
webpack.config.js
File metadata and controls
114 lines (106 loc) · 3.29 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
const webpack = require("webpack");
const path = require('path');
const url = require("url")
const fs = require("fs")
const isProduction = process.argv.indexOf("--env.compress") > -1
const isClassic = process.argv.indexOf("-d") > -1
console.log('webpack isProduction?',isProduction)
console.log('webpack isClassic?',isClassic)
// ----------------------------------------------------------------------------- PLUGINS
const BrowserSyncPlugin = require('browser-sync-webpack-plugin')
const OptimizeJsPlugin = require("optimize-js-plugin");
const BabiliPlugin = require("babili-webpack-plugin")
var plugins = [
new webpack.DefinePlugin({ isProduction: isProduction }),
new webpack.ProvidePlugin({
dat: "dat",
THREE: "three",
WAGNER: "WAGNER",
}),
new webpack.LoaderOptionsPlugin({
minimize: isProduction,
debug: !isProduction
}),
new webpack.optimize.CommonsChunkPlugin({children: true, async: true}),
]
if(isProduction){
plugins.push(new webpack.optimize.OccurrenceOrderPlugin())
plugins.push(new BabiliPlugin({}))
// plugins.push(new webpack.optimize.UglifyJsPlugin({ beautify: false, mangle: { screw_ie8: true, keep_fnames: true },compress: {warnings: false, pure_getters: true, unsafe: true, unsafe_comps: true, screw_ie8: true }, comments: false}) )
// plugins.push(new UglifyJsPlugin({ beautify: false, mangle: { screw_ie8: true, keep_fnames: true },compress: {warnings: false, screw_ie8: true }, comments: false}) )
plugins.push(new OptimizeJsPlugin({sourceMap: false}))
}
else {
if(!isClassic){
plugins.push(new webpack.HotModuleReplacementPlugin())
}else{
let defaultFile = "index.html"
let folders = [
path.resolve(__dirname, "./app"),
path.resolve(__dirname, "./src")
]
plugins.push(new BrowserSyncPlugin({ host: 'localhost', port: 9000, server: {
baseDir: ['./app','./src'],
files: [
"app/css/**/*.css",
"app/bin/*.js",
"app/vendors/*.js",
"app/*.html"
]
} }, { reload: true }))
}
}
// ----------------------------------------------------------------------------- CONFIG
module.exports = {
devtool: isProduction?false:'source-map',
entry: ['babel-polyfill',__dirname+"/src/js/Main"],
output: {
path: path.resolve(__dirname,'app/bin/'),
filename: 'bundle.js',
chunkFilename: "[id].bundle.js",
publicPath: isProduction?'./bin/':'/bin/'
},
module: {
loaders: [
{ test: /\.(glsl|frag|vert|fs|vs)$/, exclude:[/node_modules|vendors/], loader: 'shader-loader' },
{ test: /\.jsx?$/,
exclude:[/node_modules|vendors/],
loader:'babel-loader', query: {
plugins: isProduction?['transform-runtime']:[],
presets: [
['es2015',{loose:true,modules:false}],
["stage-0"],
],
retainLines:false,
} },
{
test: /\.(html)$/,
use: ['raw-loader']
},
],
},
resolve: {
extensions:['.json','.js','.glsl','.vs','.fs'],
modules: [
path.resolve(__dirname,'src/js'),
path.resolve(__dirname,'src/glsl'),
path.resolve(__dirname,'node_modules'),
path.resolve(__dirname,'app/vendors'),
],
alias: {
dat: path.resolve(__dirname+'/app/vendors/dat.gui.js'),
WAGNER: path.resolve(__dirname+'/app/vendors/WAGNER.js'),
}
},
devServer: {
open:true,
compress:true,
inline:true,
https:true,
noInfo:false,
port:9000,
contentBase: ['./app','./src'],
stats: { colors: true }
},
plugins:plugins
};