Pārlūkot izejas kodu

Refactor version replacement (#4400)

Use the rollup replace plugin to replace weexVersion and (Vue) version
inside the files
Eduardo San Martin Morote 9 gadi atpakaļ
vecāks
revīzija
b9376eb5ff
4 mainītis faili ar 6 papildinājumiem un 17 dzēšanām
  1. 0 14
      build/build.js
  2. 4 1
      build/config.js
  3. 1 1
      src/core/index.js
  4. 1 1
      src/entries/weex-framework.js

+ 0 - 14
build/build.js

@@ -8,20 +8,6 @@ if (!fs.existsSync('dist')) {
   fs.mkdirSync('dist')
 }
 
-// Update main file
-const version = process.env.VERSION || require('../package.json').version
-const main = fs
-  .readFileSync('src/core/index.js', 'utf-8')
-  .replace(/Vue\.version = '[^']+'/, "Vue.version = '" + version + "'")
-fs.writeFileSync('src/core/index.js', main)
-
-// update weex subversion
-const weexVersion = process.env.WEEX_VERSION || require('../packages/weex-vue-framework/package.json').version
-const weexMain = fs
-  .readFileSync('src/entries/weex-framework.js', 'utf-8')
-  .replace(/Vue\.version = '[^']+'/, "Vue.version = '" + weexVersion + "'")
-fs.writeFileSync('src/entries/weex-framework.js', weexMain)
-
 let builds = require('./config').getAllBuilds()
 
 // filter builds via command line arg

+ 4 - 1
build/config.js

@@ -4,6 +4,7 @@ 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 weexVersion = process.env.WEEX_VERSION || require('../packages/weex-vue-framework/package.json').version
 
 const banner =
   '/*!\n' +
@@ -103,7 +104,9 @@ function genConfig (opts) {
     moduleName: 'Vue',
     plugins: [
       replace({
-        __WEEX__: !!opts.weex
+        __WEEX__: !!opts.weex,
+        __WEEX_VERSION__: weexVersion,
+        __VERSION__: version
       }),
       flow(),
       buble(),

+ 1 - 1
src/core/index.js

@@ -8,6 +8,6 @@ Object.defineProperty(Vue.prototype, '$isServer', {
   get: isServerRendering
 })
 
-Vue.version = '2.1.4'
+Vue.version = '__VERSION__'
 
 export default Vue

+ 1 - 1
src/entries/weex-framework.js

@@ -1,7 +1,7 @@
 import Vue from 'weex/runtime/index'
 import renderer from 'weex/runtime/config'
 
-Vue.weexVersion = '2.0.5-weex.1'
+Vue.weexVersion = '__WEEX_VERSION__'
 export { Vue }
 
 const {