-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.develop.config.js
90 lines (86 loc) · 2.8 KB
/
webpack.develop.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
/**
* 项目开发环境配置文件
*/
var path = require('path');
// 自动打开浏览器插件
var OpenBrowserPlugin = require('open-browser-webpack-plugin');
module.exports = {
// entry:path.resolve(__dirname,'src/js/app.js'),
entry:[
'webpack/hot/dev-server',
'webpack-dev-server/client?http://localhost:8070',
path.resolve(__dirname,'src/js/app.js')
],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
},
eslint: {
configFile: '.eslintrc.js'
},
module: {
preLoaders: [
{ test: /\.js$/, loader: "eslint-loader", exclude: /node_modules/ }
],
loaders: [
// 处理jsx语法和ES6语法
{
test: /\.jsx?$/, // 用正则来匹配文件路径,这段意思是匹配 js 或者 jsx
loader: 'babel',// 加载模块 "babel" 是 "babel-loader" 的缩写
},
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.js$/,
loader: "eslint",
exclude: /node_modules/
},
// 处理在js中引用css
{
test: /\.css$/, // Only .css files
loader: 'style!css' // 如果有多个加载器,中间作用感叹号隔开,多个加载器是从右往左去执行
},
// 1kb=1024b 1b=8bit 25000bit~3kb
// {
// test: /\.(png|jpg|jpeg|gif)$/,
// loader: 'url?limit=25000'
// },
{
test: /\.(eot|woff|ttf|woff2|svg)$/,
loader: 'url'
},
{
test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,
loader: 'file-loader'
},
{
test: /\.(png|jpe?g|gif|svg|ico)(\?\S*)?$/,
loader: 'file-loader',
query: {
name: '[name].[ext]?[hash]'
}
}
]
},
vue: {
loaders: {
js: 'babel'
}
},
resolve: {
// 自动扩展文件后缀名,意味着我们require模块可以省略不写后缀名
// 注意一下, extensions 第一个是空字符串! 对应不需要后缀的情况.
extensions: ['', '.js', '.json', '.scss', '.vue']
// 模块别名定义,方便后续直接引用别名,无须多写长长的地址。后续直接 require('AppStore') 即可
//alias: {
// AppStore: 'js/stores/AppStores.js',
// ActionType: 'js/actions/ActionType.js',
// AppAction: 'js/actions/AppAction.js'
//}
},
plugins: [
new OpenBrowserPlugin({url: 'http://localhost:8070/', browser: '360chrome'})
]
}