-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.client.config.js
68 lines (65 loc) · 1.87 KB
/
webpack.client.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
/* eslint-disable no-var, object-shorthand, prefer-template */
var rucksack = require('rucksack-css');
var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractTextPlugin = new ExtractTextPlugin('client.css');
var env = process.env.NODE_ENV;
var plugins = [
extractTextPlugin,
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(env) }),
];
var devtool = 'eval';
var localIdentName = '[local]___[hash:base64:5]';
if (env === 'production') {
plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}));
devtool = undefined;
localIdentName = '[hash:base64:8]';
}
module.exports = {
devtool: devtool,
entry: [
'babel-polyfill',
'./src/client/index'
],
output: {
path: path.join(__dirname, 'entry'),
filename: 'client.js',
library: 'client',
libraryTarget: 'umd'
},
module: {
loaders: [{
test: /\.scss$/,
include: path.join(__dirname, 'src/client'),
loader: extractTextPlugin.extract([
'css-loader?modules&sourceMap&importLoaders=1&localIdentName=' + localIdentName,
'postcss-loader',
'sass?outputStyle=expanded'
].join('!'))
}, {
test: /\.js$/,
loader: 'babel',
include: [path.join(__dirname, 'src/client')],
exclude: /node_modules/
}],
},
resolve: {
extensions: ['', '.js', '.jsx'],
root: [
path.join(__dirname, 'src/client')
]
},
postcss: [
rucksack({ autoprefixer: true })
],
plugins: plugins,
sassLoader: {
includePaths: [path.resolve(__dirname, 'src/client')]
}
};