《基于 Vue 组件库 的 Webpack5 配置》9.module.exports 可为数组类型且注意编译顺序

时间: 2023-12-21 admin 维修知识

《基于 Vue 组件库 的 Webpack5 配置》9.module.exports 可为数组类型且注意编译顺序

《基于 Vue 组件库 的 Webpack5 配置》9.module.exports 可为数组类型且注意编译顺序

  • module.exports常见是对象类型,其实也可用数组类型;
  • 注意编译顺序,从后往前 编:
    • 也就是说先编 another.js,再编 index.js
    • 所以代码第 9 行不能设置为 true,仅在第一次,也就是代码第19行设置一次即可清空整个 output 文件夹;
    • 如果代码第 9 行设置为 true,则在编 index.js时,会删除another.js 已编译好的文件;
module.exports = [{mode: 'production',entry: {"indexs": './index.js' ,},output: {filename: '[name].js',// clean: true, }},{mode: 'production',entry: {"another": './another.js' ,},output: {filename: '[name].js',clean: true, // 在每次构建前清理 output 文件夹}}
];