-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
98 lines (94 loc) · 2.56 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
var webpack = require('webpack');
const path = require('path');
module.exports = function (env) {
const config = {
entry: [
'./client/app.jsx'
],
output: {
path: __dirname,
filename: './static/bundle.js'
},
resolve: {
modules: ['node_modules'],
alias: {
BoardAPI: path.resolve(__dirname, 'client/model/boardapi'),
SiteAPI: path.resolve(__dirname, 'client/model/siteapi'),
AuthUI: path.resolve(__dirname, 'client/emailpw/ui'),
Intro: path.resolve(__dirname, 'client/ui/intro')
},
extensions: ['.js', '.jsx', '.css']
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['react', 'es2015']
}
}
]
},
{
test: /\.css$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
modules: true,
sourceMap: true,
importLoaders: 1,
localIdentName: "[name]--[local]--[hash:base64:8]"
}
},
// has separate config, see postcss.config.js nearby
"postcss-loader"
]
},
{
test: /\.scss$/,
use: ["style-loader", "css-loader", "sass-loader" ]
},
{
test: /\.html$/,
use: ["html-loader"]
},
{ test: /\.json$/, use: ["json-loader"] }
]
},
devtool: 'cheap-module-eval-source-map'
};
if (env && env.prod) {
config.devtool = 'source-map';
config.plugins = [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin({sourceMap: true})
];
}
if (env && env.demo) {
if (env.prod) {
config.output.filename = './prod/bundle.js';
}
else {
config.output.filename = './demo/static/bundle.js';
}
config.resolve.alias = {
indexedDB: path.resolve(__dirname, 'client/demo/indexeddb'),
BoardAPI: path.resolve(__dirname, 'client/demo/boardapi'),
SiteAPI: path.resolve(__dirname, 'client/demo/siteapi'),
AuthUI: path.resolve(__dirname, 'client/demo/ui'),
Intro: path.resolve(__dirname, 'client/demo/intro'),
Sample: path.resolve(__dirname, 'client/demo/sample.json')
};
}
return config;
};