标签:target trap get require use ports eve merge proxy
devServer:{
proxy:{
‘/api‘:{
target:‘http:localhost:3000‘,
pathRewrite:{‘/api‘:‘‘}
}
}
也可以使用中间件webpack-dev-middleware
let webpack = require("webpack")
let middle = require("webpack-dev-middleware");
let compiler = webpack(config);
app.use(middle(complier));
resolve:{
modules:[path.resolve(‘node_moduels‘)],
extensions:[‘.js‘,‘.css‘,‘.json‘],//配置默认查看文件后缀名 import index from ‘index‘
alias:{
bootstrap:‘bootstrap/dist/css/bootstrap.css‘,//设置别名
}
}
plugins:[
new webpack.DefinePlugin({
DEV:JSON.stringify(‘development‘),//console.log(DEV)
PRO:‘production‘ //console.log(‘production‘)如果写字符串的话,需要加引号才能获取到
})
]
let merge = require("webpack-merge");
let base = require(‘./webpack-base.js‘);
module.exports = merge(base,{ //前面是引入的,后面是各自自定义的
mode:‘development‘,
});
noParse:/jquery/
忽略打包中某些包的某些文件不需要打包进去
plugins:[
new webpack.IgnorePlugin(/\.\locale/,/moment/)
]
标签:target trap get require use ports eve merge proxy
原文地址:https://www.cnblogs.com/cyany/p/12821130.html