-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.prod.config.js
88 lines (85 loc) · 1.97 KB
/
webpack.prod.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
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
devtool: 'source-map',
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendors',
minChunks(module, count) {
return (
module.resource &&
module.resource.indexOf(path.resolve('node_modules')) === 0
)
}
}),
new HtmlWebpackPlugin({
title: 'React redux hot demo',
template: path.join(__dirname, 'assets/index-template.html')
}),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify('production'),
'PORT': JSON.stringify('8080'),
'WS_PORT': JSON.stringify('8082')
}
}),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
}),
new ExtractTextPlugin('[name]-[hash].min.css')
],
resolve: {
extensions: ['', '.js'],
root: path.join(__dirname, 'src')
},
// ESLint options
eslint: {
configFile: '.eslintrc',
failOnWarning: false,
failOnError: true
},
module: {
preLoaders: [
{
test: /\.css$/,
loader: 'stripcomment'
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint'
}
],
loaders: [{
test: /\.js$/,
loaders: ['babel'],
include: path.join(__dirname, 'src')
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style', 'css!postcss!sass')
}, {
test: /\.json/,
loaders: ['json-loader']
},
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader',
}]
},
postcss: [
require('autoprefixer')
]
};