-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
93 lines (80 loc) · 1.98 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
var path = require('path');
var webpack = require('webpack');
var WebPackConfig = new Object();
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var onDevMode = process.argv.indexOf('--dev') > -1;
var localIdentName = process.argv.indexOf('--css-module-test') > -1 ? '[local]' : '[name]__[local]___[hash:base64:5]';
var cssLoader = [
'css?minimize&modules',
'sourceMap',
'importLoaders=1',
'localIdentName=' + localIdentName
].join('&');
WebPackConfig.output = new Object();
WebPackConfig.module = new Object();
WebPackConfig.module.loaders = new Array();
WebPackConfig.entry = ['./src/main.js'];
WebPackConfig.devtool = 'source-map';
WebPackConfig.output.filename = 'bundle.js'
WebPackConfig.output.path = __dirname + '/build/';
WebPackConfig.module.loaders.push({
test: /(\.jsx|\.js)$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
})
WebPackConfig.module.loaders.push({
test: /(\.jsx|\.js)$/,
loader: "eslint-loader",
exclude: [/node_modules/, /test/]
})
WebPackConfig.module.loaders.push({
test: /\.scss$/,
include: /src/,
loaders: [
'style',
cssLoader,
'postcss-loader',
'sass?sourceMap'
]
});
// Don't treat global SCSS as modules
WebPackConfig.module.loaders.push({
test: /\.scss$/,
exclude: /src/,
loaders: [
'style',
'css?-minimize',
'postcss-loader',
'sass?sourceMap'
]
});
// Don't treat global, third-party CSS as modules
WebPackConfig.module.loaders.push({
test: /\.css$/,
exclude: /src/,
loaders: [
'style',
cssLoader,
'postcss-loader'
]
});
WebPackConfig.sassLoader = {
includePaths: [path.resolve('src/styles/')]
};
WebPackConfig.resolve = {
root: path.resolve('src/'),
extensions: ['', '.js', '.jsx']
};
WebPackConfig.module.postcss = [
require('autoprefixer-core'),
require('postcss-color-rebeccapurple')
];
WebPackConfig.plugins = [
new ExtractTextPlugin('style.css', {
allChunks: true
})
];
module.exports = WebPackConfig;