forked from duxianwei520/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.development.config.js
More file actions
105 lines (102 loc) · 3.19 KB
/
Copy pathwebpack.development.config.js
File metadata and controls
105 lines (102 loc) · 3.19 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
const webpack = require('webpack')
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const OpenBrowserPlugin = require('open-browser-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
// const casProxy = require('./proxy');
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const PORT = 3010
module.exports = {
entry: {
client: './app/client.js',
a: ['immutable'],
vendor: [
'react', 'classnames', 'react-router', 'react-dom',
],
},
output: {
// path: path.resolve(__dirname, 'dist'),
// filename: './vendor.js',
filename: '[name].js',
path: path.join(__dirname, 'dist'),
chunkFilename: '[name].js',
},
resolve: {
extensions: ['', '.js', '.json'],
alias: {
components: __dirname + '/app/components',
actions: __dirname + '/app/actions',
api: __dirname + '/app/api',
reducers: __dirname + '/app/reducers',
utils: __dirname + '/app/utils',
constants: __dirname + '/app/constants',
controllers: __dirname + '/app/controllers',
style: __dirname + '/app/style',
},
},
module: {
loaders: [
{
test: /\.js[x]?$/,
exclude: /node_modules/,
// loader: 'react-hot!babel', // 暂时不用react-hot-loader
loader: 'babel',
},
{
test: /\.less$/,
// loader: 'style!css!postcss!less',
loader: ExtractTextPlugin.extract('style-loader', 'css-loader?sourceMap=true!postcss-loader?sourceMap=true!less-loader?sourceMap=<true></true>'),
},
{
test: /\.css/,
// loader: 'style!css',
loader: ExtractTextPlugin.extract('style-loader', 'css-loader?sourceMap=true!postcss-loader?sourceMap=true!less-loader?sourceMap=<true></true>'),
},
{
test: /\.(png|jpg)$/,
loader: 'url-loader?limit=8192',
},
{
test: /\.(woff|eot|ttf|svg|gif)$/,
loader: 'file-loader?name=iconfont/[path][name].[ext]',
},
],
},
plugins: [
// 定义环境变量为开发环境
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development'),
IS_DEVELOPMETN: true,
}),
// 提取css
new ExtractTextPlugin('vendor.[hash].css'),
// 根据入口文件,提取重复引用的公共代码类库,打包到单独文件中
// new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor', // 入口文件名
filename: 'vendor.bundle.js', // 打包后的文件名
}),
/* 压缩优化代码开始 可以关掉*/
// new webpack.optimize.UglifyJsPlugin({minimize: true}),
/* 压缩优化代码结束*/
new HtmlWebpackPlugin({
template: path.join(__dirname, 'app/index.html'),
}),
new OpenBrowserPlugin({
url: `http://localhost:${PORT}/#/login`,
}),
// 分析代码
// new BundleAnalyzerPlugin({ analyzerPort: 666 }),
],
devtool: 'source-map',
devServer: {
contentBase: './app/',
historyApiFallback: false,
hot: false,
// inline: false,
// proxy: casProxy(),
host: '0.0.0.0',
port: PORT,
// stats: { colors: true },
},
}