forked from SmoofCreative/kasban
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
89 lines (76 loc) · 2.15 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
var path = require('path');
var rucksack = require('rucksack-css');
var webpack = require('webpack');
var NODE_ENV = JSON.stringify(process.env.NODE_ENV || 'development');
var CLIENT_ID = JSON.stringify(process.env.CLIENT_ID || '');
var TYPEKIT_KIT_ID = JSON.stringify(process.env.TYPEKIT_KIT_ID || '');
var GOOGLE_ANALYTICS_ID = JSON.stringify(process.env.GOOGLE_ANALYTICS_ID || '');
var isDevelopment = (NODE_ENV == JSON.stringify('development'));
var isProduction = (NODE_ENV == JSON.stringify('production'));
console.log('NODE_ENV', NODE_ENV);
console.log('CLIENT_ID', CLIENT_ID);
console.log('TYPEKIT_KIT_ID', TYPEKIT_KIT_ID);
console.log('GOOGLE_ANALYTICS_ID', GOOGLE_ANALYTICS_ID);
var devTool = isDevelopment ? 'eval' : 'source-map';
var entry = ['./app/index.jsx'];
if (isDevelopment) {
entry.push('webpack/hot/dev-server', 'webpack-dev-server/client?http://localhost:8080');
}
var plugins = [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: NODE_ENV,
CLIENT_ID: CLIENT_ID,
TYPEKIT_KIT_ID: TYPEKIT_KIT_ID,
GOOGLE_ANALYTICS_ID: GOOGLE_ANALYTICS_ID
}
})
];
if (isDevelopment) {
plugins.push(new webpack.HotModuleReplacementPlugin());
}
if (isProduction) {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
minimize: true,
compress: {
warnings: false
}
})
);
}
var preLoaders = [];
if (isDevelopment) {
preLoaders.push({ test: /\.jsx?$/, exclude: /node_modules/, loader: 'eslint' });
}
var config = {
devtool: devTool,
entry: entry,
output: {
path: path.join(__dirname, 'build'),
filename: 'bundle.js',
publicPath: '/public/'
},
module: {
preLoaders: preLoaders,
loaders: [
{ test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader' },
{ test: /\.scss$/, loader: 'style-loader!css-loader!sass!postcss-loader' },
{ test: /\.json$/, loader: 'json-loader' }
]
},
postcss: [
rucksack({
autoprefixer: true
})
],
resolve: {
extensions: ['', '.js', '.jsx', '.json', '.scss'],
modulesDirectories: ['node_modules']
},
node: {
readline: 'empty'
},
plugins: plugins
};
module.exports = config;