用到 @angular-builders/custom-webpack
依赖
npm i -D @angular-builders/custom-webpack@8.4.1
或者 yarn add @angular-builders/custom-webpack@8.4.1 --dev
{
// ...省略配置
"projects": {
"project-name": {
// ...省略配置
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
// ...省略配置
"customWebpackConfig": {
"path": "./webpack.config.js"
}
},
// ...省略配置
},
"serve": {
"builder": "@angular-builders/custom-webpack:dev-server",
// ...省略配置
},
// ...省略配置
}
}
},
// ...省略配置
}
module.exports = config => {
console.log('config === ', config);
config.devServer = Object.assign(config.devServer, {
port: 9000,
before: (app, server, compiler) => {
app.get('/list', (req, res)=>{
res.json({ success: true, code: 200, data: [] });
})
},
})
return config;
}
npm start
运行看端口和mock的数据已经成功运行了