-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.config.js
103 lines (90 loc) · 2.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
94
95
96
97
98
99
100
101
102
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var NODE_ENV = process.env.NODE_ENV || 'development';
var devtoolConfig = (NODE_ENV === 'production') ? false : '#source-map';
console.log('node_env: ' + NODE_ENV);
console.log('devtool config: ' + devtoolConfig);
var configuration = {
devtool: devtoolConfig,
entry: {
global: ['babel-polyfill', './app/index.js'],
admin: './app/modules/reactHelpDeskAdmin/admin.js'
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'js/[name].min.js',
publicPath: '/'
},
module: {
loaders: [
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style-loader',
loader: 'css-loader?sourceMap'
})
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: 'style-loader',
loader: 'css-loader?sourceMap!postcss-loader!sass-loader?sourceMap',
includePaths: [path.resolve(__dirname, './app/scss')]
})
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: ['file-loader?hash=sha512&digest=hex&name=images/[name]-[hash].[ext]']
},
{
test: /\.(eot|ttf|woff(2)?)(\?v=\d+\.\d+\.\d+)?/,
loader: 'file-loader?name=fonts/[name].[ext]'
},
{ test: /\.js$/, loader: 'eslint-loader', exclude: /node_modules/ }
]
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, 'app', 'index.html'),
filename: 'index.html',
inject: 'body'
}),
new ExtractTextPlugin('./css/[name].min.css'),
new webpack.LoaderOptionsPlugin({
options: {
context: '/',
postcss: [
require('autoprefixer')({
browsers: ['> 2%', 'IE 10']
})
]
}
}),
new CopyWebpackPlugin([
{context: './app/modules/reactHelpDesk/libs/sounds', from: '**/**', to: 'sounds'},
])
]
};
if (NODE_ENV === 'production') {
var uglify = new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
comments: false
});
var definePlugin = new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(NODE_ENV)
}
});
configuration.plugins.concat([uglify, definePlugin])
}
module.exports = configuration;