-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.prod.js
More file actions
106 lines (104 loc) · 3.29 KB
/
webpack.config.prod.js
File metadata and controls
106 lines (104 loc) · 3.29 KB
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
103
104
105
106
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
module.exports = {
context: path.join(__dirname, './src'),
entry: {
app: './Index.jsx',
lib: [
'react',
'react-dom',
'react-redux',
'react-router',
'react-router-redux',
'redux',
],
},
output: {
path: path.join(__dirname, './dist'),
filename: '[name].[chunkhash:10].js',
},
module: {
rules: [
{
test: /\.less$/,
exclude: path.resolve(__dirname, './node_modules'),
loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader?modules&minimize&camelCase&importLoaders=1&localIdentName=[local]__[hash:base64:6]!postcss-loader!less-loader' }),
},
{
test: /\.css$/,
exclude: path.resolve(__dirname, './node_modules'),
loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader?modules&minimize&camelCase&importLoaders=1&localIdentName=[local]__[hash:base64:6]!postcss-loader' }),
},
{
test: /\.less$/,
include: path.resolve(__dirname, './node_modules'),
loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader!postcss-loader!less-loader' }),
},
{
test: /\.css$/,
include: path.resolve(__dirname, './node_modules'),
loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader!postcss-loader' }),
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loaders: [
'react-hot-loader',
'babel-loader',
],
},
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192&name=[name]_[hash:6].[ext]' },
],
},
resolve: {
alias: {
react: path.join(__dirname, 'node_modules', 'react'),
},
extensions: ['.js', '.jsx', '.json'],
},
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
context: __dirname,
postcss: [
autoprefixer({
browsers: ['last 10 Chrome versions', 'last 5 Firefox versions', 'Safari >= 6', 'ie > 8'],
}),
],
},
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks(module) {
// this assumes your vendor imports exist in the node_modules directory
return module.context && module.context.indexOf('node_modules') !== -1;
},
}),
// The manifest bundle has the code for the webpack runtime
// https://webpack.js.org/guides/code-splitting-libraries/#manifest-file
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
chunks: ['vendor'],
}),
new ExtractTextPlugin('[name].[chunkhash:10].css'),
new webpack.DefinePlugin({
'process.env': { NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development') },
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
unused: true,
dead_code: true,
warnings: false,
},
}),
new HtmlWebpackPlugin({
minify: {},
template: './index.html',
}),
],
};