跳转至主要内容

C'est La Vie

webpack打包成单js文件的配置

hliang
最后编辑于 2024年9月5日

webpack.config.js

const path = require('path');
// const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
    entry: './main.js',
    output: {
        path: path.resolve('./dist'),
        filename: 'merge.min.js',
    },
    mode: 'production',
    target: 'node',
    node: {
        global: true,
        __filename: false,
        __dirname: false,
    },
    module: {
        rules: [],
    },
    // optimization: {
    //     minimize: true,
    //     minimizer: [
    //         new TerserPlugin({
    //             extractComments: false, // 不将注释提取到单独的文件中
    //         }),
    //     ],
    // },
};

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注