文件路徑:/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