VUE2.6.10——scripts/config.js

发布时间:2019-08-12 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了VUE2.6.10——scripts/config.js脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

文件路径:/scripts/config.js

rollup -w -c scripts/config.js --environment TargET:web-full-dev
-c 指定配置文件
-w 监听文件,文件发生改变时重新构建
--environment 设置环境变量。如rollup -c --environment TARGET:web-full-dev 可以通过PRocess.env.TARGET获取

if (process.env.TARGET) {         // 根据TARGET生成rollup config对象
  module.exports = genConfig(process.env.TARGET)   //生成rollup config对象
} else {  //如果没有设置TARGET,返回生成函数
  exports.getBuild = genConfig
  exports.getAllBuilds = () => Object.keys(builds).map(genConfig)
}

rollup -w -c scripts/config.js --environment TARGET:web-full-dev 对应rollup config对象如下:

{
    input: opts.entry,       //入口 src/platforms/web/entry-runtime-with-compiler.js
    external: opts.external,
    plugins: [
      flow(),
      alias(Object.assign({}, aliases,  { he: './entity-decoder' }))
    ].concat(opts.plugins || []),
    output: {
      file:  resolve('dist/vue.js'),
      format: 'umd',                  // umd – 通用模块定义,以amd,cjs 和 iife 为一体
      banner: opts.banner, 
      name: opts.moduleName || 'Vue'
    },
    onwarn: (msg, warn) => {            //拦截警告信息
      if (!/Circular/.test(msg)) {
        warn(msg)
      }
    }
}
  • rollup-plugin-flow-no-whitespace //去除flow静态类型检查代码
  • rollup-plugin-alias //为模块提供别名
  • rollup-plugin-buble //编译ES6+语法为ES2015,无需配置,比babel更轻量
  • rollup-plugin-replace //替换代码中的变量为指定值

参考资料:
1、rollup文档

脚本宝典总结

以上是脚本宝典为你收集整理的VUE2.6.10——scripts/config.js全部内容,希望文章能够帮你解决VUE2.6.10——scripts/config.js所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。