-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.dev.js
81 lines (79 loc) · 2.29 KB
/
webpack.dev.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
/**
* Created by shenqiao on 2017/12/20.
*/
const path = require('path')
const root = __dirname + '/web'
const HtmlWebpackPlugin = require('html-webpack-plugin')
const webpack = require('webpack')
const proxy = require('http-proxy-middleware')
const context = ['/channel/**', '/customer/**']; //解决跨域问题
console.log(root);
const json = require('./package.json')
module.exports = {
// 入口文件
//entry: [
// 'react-hot-loader/patch', // 激活HMR
// 'webpack-dev-server/client',
// 'webpack/hot/only-dev-server',
// path.resolve(root, 'src/main.js')
//],
//解决ie11promise未定义的问题
// 出口文件
//这里改动最大。至于改动了什么,我也忘记了
entry: {
app: path.resolve(root, 'src/main.js')
// vendor: Object.keys(json.dependencies)
},
// entry: [
// "babel-polyfill", "./web/src/main.js",
// ],
output: {
filename: 'bundle.js',
path: path.resolve(root, 'dist')
},
// loaders
module: {
rules: [{
test: /\.jsx?$/,
use: ['babel-loader'],
exclude: /node_modules/
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
},
]
},
plugins: [
new HtmlWebpackPlugin({
title: 'React Demo',
template: path.resolve(root, 'template.html')
})
// new webpack.optimize.CommonsChunkPlugin({
// name: 'vendor',
// minChunks: function (module, count) {
// // any required modules inside node_modules are extracted to vendor
// return (
// module.resource &&
// /\.js$/.test(module.resource) &&
// module.resource.indexOf(
// path.join(__dirname, '../node_modules')
// ) === 0
// )
// }
// })
],
devServer: {
contentBase: path.resolve(root, 'dist'),
publicPath: '/',
port: 8080,
historyApiFallback: true,
//proxy: [
// {
// context: context,
// target: 'http://localhost:9527',
// secure: false
// }
//]
}
}