問題
angular升級后,推薦使用angular-cli創(chuàng)建打包項目逛腿,但是有特殊的需求是就顯然不是很靈活稀并。
例如,團(tuán)隊之前要求前端項目都build成zip包单默,webpack配置倒是挺簡單,問題是angular封裝了webpack后忘瓦,不知道在哪里能增加配置
解決辦法
好在angular還是提供了外掛一樣的方式搁廓。
--extra-webpack-config
增加npm依賴
ngx-build-plus
這個參數(shù)可以額外指定一個webpack config 文件
使用方式
配置webpack文件
webpack config文件內(nèi)容
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin') ;
var ZipPlugin = require('zip-webpack-plugin')
module.exports = {
plugins: [
new HtmlWebpackPlugin({
filename: 'download.html',
excludeChunks: ['main','runtime','styles','polyfills'],
template: './src/download.html',
title: 'test Title'
}),
new ZipPlugin({
path:path.join(__dirname,'zip'),
filename: 'test.zip',
// pathPrefix: 'zip',
}),
],
}