Просмотр исходного кода

build: fix feature flags for esm builds

Evan You 7 лет назад
Родитель
Сommit
2afa1d056e
1 измененных файлов с 14 добавлено и 14 удалено
  1. 14 14
      scripts/config.js

+ 14 - 14
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,
-  // e.g. Rollup & Webpack 2
+  // Runtime only ES modules build (for bundlers)
   '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 = {
-      'process.env.NODE_ENV': JSON.stringify(opts.env)
-    }
-    Object.keys(featureFlags).forEach(key => {
-      vars[`process.env.${key}`] = featureFlags[key]
-    })
-    config.plugins.push(replace(vars))
+    vars['process.env.NODE_ENV'] = JSON.stringify(opts.env)
   }
   }
+  config.plugins.push(replace(vars))
 
 
   if (opts.transpile !== false) {
   if (opts.transpile !== false) {
     config.plugins.push(buble())
     config.plugins.push(buble())