-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
111 lines (110 loc) · 3.14 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
103
104
105
106
107
108
109
110
111
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const DashboardPlugin = require('webpack-dashboard/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].js',
},
module: {
rules: [
{
enforce: 'pre', // run before the build process
test: /(\.js$|\.jsx$)/,
loader: 'eslint-loader',
exclude: /node_modules/,
options: {
fix: true,
},
},
{
test: /\.less$/,
exclude: path.resolve(__dirname, './node_modules'),
loader: 'style-loader!css-loader?modules&camelCase&importLoaders=1&localIdentName=[local]__[hash:base64:6]!postcss-loader!less-loader',
},
{
test: /\.css$/,
exclude: path.resolve(__dirname, './node_modules'),
loader: 'style-loader!css-loader?modules&camelCase&importLoaders=1&localIdentName=[local]__[hash:base64:6]!postcss-loader',
},
{
test: /\.less$/,
include: path.resolve(__dirname, './node_modules'),
loader: 'style-loader!css-loader!postcss-loader!less-loader',
},
{
test: /\.css$/,
include: path.resolve(__dirname, './node_modules'),
loader: 'style-loader!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 DashboardPlugin(),
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 webpack.DefinePlugin({
'process.env': { NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development') },
}),
new HtmlWebpackPlugin({
template: './index.html',
}),
],
devServer: {
stats: { chunks: false },
contentBase: './src',
hot: true,
port: 6060,
},
};