Skip to content

Commit b9376eb

Browse files
posvayyx990803
authored andcommitted
Refactor version replacement (vuejs#4400)
Use the rollup replace plugin to replace weexVersion and (Vue) version inside the files
1 parent 4da64ee commit b9376eb

File tree

4 files changed

+6
-17
lines changed

4 files changed

+6
-17
lines changed

build/build.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@ if (!fs.existsSync('dist')) {
88
fs.mkdirSync('dist')
99
}
1010

11-
// Update main file
12-
const version = process.env.VERSION || require('../package.json').version
13-
const main = fs
14-
.readFileSync('src/core/index.js', 'utf-8')
15-
.replace(/Vue\.version = '[^']+'/, "Vue.version = '" + version + "'")
16-
fs.writeFileSync('src/core/index.js', main)
17-
18-
// update weex subversion
19-
const weexVersion = process.env.WEEX_VERSION || require('../packages/weex-vue-framework/package.json').version
20-
const weexMain = fs
21-
.readFileSync('src/entries/weex-framework.js', 'utf-8')
22-
.replace(/Vue\.version = '[^']+'/, "Vue.version = '" + weexVersion + "'")
23-
fs.writeFileSync('src/entries/weex-framework.js', weexMain)
24-
2511
let builds = require('./config').getAllBuilds()
2612

2713
// filter builds via command line arg

build/config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const buble = require('rollup-plugin-buble')
44
const replace = require('rollup-plugin-replace')
55
const alias = require('rollup-plugin-alias')
66
const version = process.env.VERSION || require('../package.json').version
7+
const weexVersion = process.env.WEEX_VERSION || require('../packages/weex-vue-framework/package.json').version
78

89
const banner =
910
'/*!\n' +
@@ -103,7 +104,9 @@ function genConfig (opts) {
103104
moduleName: 'Vue',
104105
plugins: [
105106
replace({
106-
__WEEX__: !!opts.weex
107+
__WEEX__: !!opts.weex,
108+
__WEEX_VERSION__: weexVersion,
109+
__VERSION__: version
107110
}),
108111
flow(),
109112
buble(),

src/core/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ Object.defineProperty(Vue.prototype, '$isServer', {
88
get: isServerRendering
99
})
1010

11-
Vue.version = '2.1.4'
11+
Vue.version = '__VERSION__'
1212

1313
export default Vue

src/entries/weex-framework.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Vue from 'weex/runtime/index'
22
import renderer from 'weex/runtime/config'
33

4-
Vue.weexVersion = '2.0.5-weex.1'
4+
Vue.weexVersion = '__WEEX_VERSION__'
55
export { Vue }
66

77
const {

0 commit comments

Comments
 (0)