首页 新闻 会员 周边

angular 项目改用 esbuild 后如何迁移 extra-webpack.config.js

0
悬赏园豆:30 [待解决问题]

升级到 angular 17 后准备使用 esbuild,切换到 esbuild 很简单,只需在 angular.json 中将

"builder": "@angular-builders/custom-webpack:browser"

替换为

"builder": "@angular-devkit/build-angular:browser-esbuild"

另外需要删除下面 webpack 配置

"customWebpackConfig": {
    "path": "./extra-webpack.config.js",
    "replaceDuplicatePlugins": true,
    "mergeRules": {
        "module": {
            "rules": "prepend"
        }
    }
}

但 extra-webpack.config.js 中配置需要迁移到 esbuild,请问如何迁移?

webpack = require('webpack');

module.exports = {
    plugins: [
        new webpack.DefinePlugin({
            APPVERSION: JSON.stringify('20230823'),
        }),
    ],
    module: {
        rules: [
            {
                test: /tinymce5\.skin\.(le|c)ss$/i,
                use: ['style-loader', 'css-loader', 'postcss-loader', 'less-loader'],
            },
            {
                test: /tinymce5\.content\.(le|c)ss$/i,
                use: ['css-loader', 'postcss-loader', 'less-loader'],
            },
        ],
    },
    devServer: {
        client: {
            logging: 'verbose',
        },
        onListening: function ({ options: { proxy }, compiler }) {
            console.info(
                '\x1b[32m',
                '\nUsing proxy.conf:\n' + JSON.stringify(proxy, undefined, 2),
                '\x1b[0m'
            );
        },
    },
};
dudu的主页 dudu | 高人七级 | 园豆:30925
提问于:2024-04-14 21:36
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册