webpack打包umd配置

4,274 阅读1分钟

首先需要安装 webpack 和 webpack-cli,然后添加如下配置:

module.exports = {
    output: {
        library: {
            name: 'MyLibrary',
            type: 'umd',
        },
        globalObject: 'this'
    }
};

然后在 package.json 中添加一个命令,build,内容为 webpack 即可。

然后打包就可以了