文件路径:/scripts/config.jsvue
rollup -w -c scripts/config.js --environment TARGET:web-full-dev
-c
指定配置文件-w
监听文件,文件发生改变时从新构建--environment
设置环境变量。如rollup -c --environment TARGET:web-full-dev
能够经过process.env.TARGET
获取web
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对象以下:babel
{ 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文档ide