angular中自定义webpack配置
生活随笔
收集整理的這篇文章主要介紹了
angular中自定义webpack配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
用到 @angular-builders/custom-webpack 依賴
安裝 custom-webpack
- angular - 8.2.14
- @angular-builders/custom-webpack - 8.4.1
npm i -D @angular-builders/custom-webpack@8.4.1 或者 yarn add @angular-builders/custom-webpack@8.4.1 --dev
調整angular.json
{// ...省略配置"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",// ...省略配置},// ...省略配置}}},// ...省略配置 }webpack.config.js
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的數據已經成功運行了
總結
以上是生活随笔為你收集整理的angular中自定义webpack配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Device模块管理设备信息,用于获取手
- 下一篇: 互联网思维和项目管理