Browse Source

build: fix feature flags for esm builds

dev
Evan You 6 years ago
parent
commit
2afa1d056e
  1. 28
      scripts/config.js

28
scripts/config.js

@ -68,8 +68,7 @@ const builds = {
alias: { he: './entity-decoder' }, alias: { he: './entity-decoder' },
banner banner
}, },
// Runtime only (ES Modules). Used by bundlers that support ES Modules, // Runtime only ES modules build (for bundlers)
// e.g. Rollup & Webpack 2
'web-runtime-esm': { 'web-runtime-esm': {
entry: resolve('web/entry-runtime.js'), entry: resolve('web/entry-runtime.js'),
dest: resolve('dist/vue.runtime.esm.js'), dest: resolve('dist/vue.runtime.esm.js'),
@ -220,11 +219,6 @@ function genConfig (name) {
input: opts.entry, input: opts.entry,
external: opts.external, external: opts.external,
plugins: [ plugins: [
replace({
__WEEX__: !!opts.weex,
__WEEX_VERSION__: weexVersion,
__VERSION__: version
}),
flow(), flow(),
alias(Object.assign({}, aliases, opts.alias)) alias(Object.assign({}, aliases, opts.alias))
].concat(opts.plugins || []), ].concat(opts.plugins || []),
@ -241,15 +235,21 @@ function genConfig (name) {
} }
} }
// built-in vars
const vars = {
__WEEX__: !!opts.weex,
__WEEX_VERSION__: weexVersion,
__VERSION__: version
}
// feature flags
Object.keys(featureFlags).forEach(key => {
vars[`process.env.${key}`] = featureFlags[key]
})
// build-specific env
if (opts.env) { if (opts.env) {
const vars = { vars['process.env.NODE_ENV'] = JSON.stringify(opts.env)
'process.env.NODE_ENV': JSON.stringify(opts.env)
}
Object.keys(featureFlags).forEach(key => {
vars[`process.env.${key}`] = featureFlags[key]
})
config.plugins.push(replace(vars))
} }
config.plugins.push(replace(vars))
if (opts.transpile !== false) { if (opts.transpile !== false) {
config.plugins.push(buble()) config.plugins.push(buble())

Loading…
Cancel
Save