forked from justpushCar/blog
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.dev.config.js
87 lines (84 loc) · 2.95 KB
/
webpack.dev.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
var path = require('path');
var webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CleanPlugin = require('clean-webpack-plugin');
var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
module.exports = {
entry: {
vendor: ['react','redux','react-redux','react-router','redux-thunk','react-dom'],
bundle: ['webpack-hot-middleware/client','./src/client/index']
},
output: {
path: path.resolve(__dirname, "/"), //静态资源会再这目录下
filename: "js/[name].js",
chunkFilename: "js/[name].js",
publicPath: "/" //html里面的引用路径会变成这个
},
resolve: {
extensions: ['', '.js', '.less', '.css', '.png', '.jpg'], //第一个是空字符串! 对应不需要后缀的情况.
root: './src',
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
//loader: 'babel?presets[]=es2015&presets[]=react'
loader: 'babel-loader',
query: {
presets: [["es2015", { "loose": true }],'react','stage-0'],
// plugins: ["transform-es5-property-mutators","transform-jscript","transform-es3-property-literals","transform-es3-member-expression-literals",]
}
}, {
test: /\.css$/,
exclude: /node_modules/,
loader: "style!css",
//loader: ExtractTextPlugin.extract('style', 'css')
}, {
test: /\.less$/,
exclude: /node_modules/,
loader: "style!css!less",
//loader: ExtractTextPlugin.extract('style', 'css!less')
}, {
test: /\.(png|jpg|jpeg|gif)$/,
exclude: /node_modules/,
loader: 'url?limit=10000&name=img/[name].[hash].[ext]'
}, {
test: /\.woff|\.woff2|\.svg|.eot|\.ttf/,
exclude: /node_modules/,
loader: 'url?prefix=font/&limit=10000&name=font/[name].[ext]'
}],
// postLoaders: [{
// test: /\.js$/,
// exclude: /node_modules/,
// loaders: ['es3ify-loader'],
// }]
},
plugins: [
// new ExtractTextPlugin('[name].css', {
// allChunks: true
// }),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
// new HtmlWebpackPlugin({
// filename: 'index.html',
// template: './index.html'
// }),
new webpack.DefinePlugin({
__DEVSERVER__:true,
'process.env.NODE_ENV': JSON.stringify('development')
}),
],
// devServer: {
// port: 7070,
// hot: true,
// historyApiFallback: true,
// publicPath: "",
// stats: {
// colors: true
// },
// plugins: [
// new webpack.HotModuleReplacementPlugin()
// ]
// }
}