-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
executable file
·114 lines (105 loc) · 3.24 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
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
let webpack = require('webpack');
module.exports = (env={}) => {
let config = {
entry: {
root: './components/root.jsx'
},
output: {
path: 'static',
filename: '[name].js',
},
module: {
rules: [
{
test: /\.jsx?$/,
use: [
{
loader: 'babel-loader',
options: {
presets: babelPresets = [
['es2015', { modules: false }],
'react', 'stage-0'
],
plugins: [
'transform-decorators-legacy',
'transform-class-properties'
]
}
}
]
},
{
test: /\.scss/,
use: [
{ loader:'style-loader' },
{ loader:'css-loader?modules&localIdentName=[hash:base64:5]' },
{ loader:'sass-loader' }
]
},
{
test: /\.svg$/,
use: [
{ loader:'raw-loader', },
{ loader:'svgo-loader' },
]
},
{
test: /\.json$/,
use: [{ loader:'json-loader' }]
}
]
},
plugins: [
new webpack.DefinePlugin({
__DEV__: env.dev
}),
new webpack.ProvidePlugin({
React: 'react',
THREE: '!!three/build/three.min.js'
}),
],
resolve: {
extensions: ['.js', '.json', '.jsx'],
alias: {
'#lib': __dirname + '/lib',
'#state': __dirname + '/state',
'#components': __dirname + '/components',
'#sass': __dirname + '/components/variables.scss',
}
}
}
if (env.devServer) {
config.output.path = '/';
config.devServer = {
contentBase: __dirname + '/templates'
};
}
if (env.dev) {
config.module.rules.push({
test: /\.jsx?$/,
enforce: 'pre',
loader: 'eslint-loader',
exclude: /lib/,
options: {
configFile: '.eslintrc',
failOnWarning: false,
failOnError: false,
emitError: false,
fix: true
}
})
// config.devtool = 'source-map';
}
if (env.closure) {
let ClosureCompiler = require('google-closure-compiler-js').webpack;
config.plugins.push(new ClosureCompiler({
options: {
languageIn: 'ECMASCRIPT5',
languageOut: 'ECMASCRIPT5',
compilationLevel: 'ADVANCED',
warningLevel: 'QUIET',
},
}));
}
return config;
};