mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-04 21:17:55 +08:00
109 lines
3.3 KiB
JavaScript
109 lines
3.3 KiB
JavaScript
const path = require('path')
|
|
const flow = require('./rollup-plugin-flow')
|
|
const buble = require('rollup-plugin-buble')
|
|
const replace = require('rollup-plugin-replace')
|
|
const alias = require('rollup-plugin-alias')
|
|
const version = process.env.VERSION || require('../package.json').version
|
|
|
|
const banner =
|
|
'/*!\n' +
|
|
' * Vue.js v' + version + '\n' +
|
|
' * (c) 2014-' + new Date().getFullYear() + ' Evan You\n' +
|
|
' * Released under the MIT License.\n' +
|
|
' */'
|
|
|
|
const baseAlias = {
|
|
vue: path.resolve(__dirname, '../src/entries/web-runtime-with-compiler'),
|
|
compiler: path.resolve(__dirname, '../src/compiler'),
|
|
core: path.resolve(__dirname, '../src/core'),
|
|
shared: path.resolve(__dirname, '../src/shared'),
|
|
web: path.resolve(__dirname, '../src/platforms/web'),
|
|
server: path.resolve(__dirname, '../src/server'),
|
|
entries: path.resolve(__dirname, '../src/entries'),
|
|
sfc: path.resolve(__dirname, '../src/sfc')
|
|
}
|
|
|
|
const builds = {
|
|
// Runtime only (CommonJS). Used by bundlers e.g. Webpack & Browserify
|
|
'web-runtime-dev': {
|
|
entry: path.resolve(__dirname, '../src/entries/web-runtime.js'),
|
|
dest: path.resolve(__dirname, '../dist/vue.common.js'),
|
|
format: 'cjs'
|
|
},
|
|
// Minified runtime, only for filze size monitoring
|
|
'web-runtime-prod': {
|
|
entry: path.resolve(__dirname, '../src/entries/web-runtime.js'),
|
|
dest: path.resolve(__dirname, '../dist/vue.common.min.js'),
|
|
format: 'umd',
|
|
env: 'production'
|
|
},
|
|
// Runtime+compiler standalone developement build.
|
|
'web-standalone-dev': {
|
|
entry: path.resolve(__dirname, '../src/entries/web-runtime-with-compiler.js'),
|
|
dest: path.resolve(__dirname, '../dist/vue.js'),
|
|
format: 'umd',
|
|
env: 'development',
|
|
banner,
|
|
alias: {
|
|
entities: './entity-decoder'
|
|
}
|
|
},
|
|
// Runtime+compiler standalone production build.
|
|
'web-standalone-prod': {
|
|
entry: path.resolve(__dirname, '../src/entries/web-runtime-with-compiler.js'),
|
|
dest: path.resolve(__dirname, '../dist/vue.min.js'),
|
|
format: 'umd',
|
|
env: 'production',
|
|
banner,
|
|
alias: {
|
|
entities: './entity-decoder'
|
|
}
|
|
},
|
|
// Web compiler (CommonJS).
|
|
'web-compiler': {
|
|
entry: path.resolve(__dirname, '../src/entries/web-compiler.js'),
|
|
dest: path.resolve(__dirname, '../packages/vue-template-compiler/build.js'),
|
|
format: 'cjs',
|
|
external: ['entities', 'de-indent']
|
|
},
|
|
// Web server renderer (CommonJS).
|
|
'web-server-renderer': {
|
|
entry: path.resolve(__dirname, '../src/entries/web-server-renderer.js'),
|
|
dest: path.resolve(__dirname, '../packages/vue-server-renderer/build.js'),
|
|
format: 'cjs',
|
|
external: ['stream', 'module', 'vm', 'entities', 'de-indent']
|
|
}
|
|
}
|
|
|
|
function genConfig (opts) {
|
|
const config = {
|
|
entry: opts.entry,
|
|
dest: opts.dest,
|
|
external: opts.external,
|
|
format: opts.format,
|
|
banner: opts.banner,
|
|
moduleName: 'Vue',
|
|
plugins: [
|
|
flow(),
|
|
buble(),
|
|
alias(Object.assign({}, baseAlias, opts.alias))
|
|
]
|
|
}
|
|
|
|
if (opts.env) {
|
|
config.plugins.push(replace({
|
|
'process.env.NODE_ENV': JSON.stringify(opts.env),
|
|
'process.env.VUE_ENV': JSON.stringify('client')
|
|
}))
|
|
}
|
|
|
|
return config
|
|
}
|
|
|
|
if (process.env.TARGET) {
|
|
module.exports = genConfig(builds[process.env.TARGET])
|
|
} else {
|
|
exports.getBuild = name => genConfig(builds[name])
|
|
exports.getAllBuilds = () => Object.keys(builds).map(name => genConfig(builds[name]))
|
|
}
|