1
1
const alias = require ( 'rollup-plugin-alias' )
2
2
const commonjs = require ( 'rollup-plugin-commonjs' )
3
+ const resolve = require ( 'rollup-plugin-node-resolve' )
3
4
const buble = require ( 'rollup-plugin-buble' )
4
5
const replace = require ( 'rollup-plugin-replace' )
5
6
const flow = require ( 'rollup-plugin-flow-no-whitespace' )
@@ -17,85 +18,77 @@ const banner = (name, version) => `
17
18
*/
18
19
`
19
20
const resolveVue = p => {
20
- return path . resolve ( process . cwd ( ) , 'node_modules' , 'vue/src/' , p ) + '/'
21
+ return path . resolve ( process . cwd ( ) , 'node_modules' , 'vue/src/' , p ) + '/'
21
22
}
22
23
const aliases = {
23
- vue : resolveVue ( 'core/index' ) ,
24
- compiler : resolveVue ( 'compiler' ) ,
25
- web : resolveVue ( 'platforms/web' ) ,
26
- core : resolveVue ( 'core' ) ,
27
- shared : resolveVue ( 'shared' ) ,
28
- sfc : resolveVue ( 'sfc' ) ,
29
- //he: path.resolve(__dirname, 'node_modules', 'he', 'he')
30
- he : path . resolve ( process . cwd ( ) , 'platform/nativescript/util/entity-decoder' )
24
+ vue : resolveVue ( 'core/index' ) ,
25
+ compiler : resolveVue ( 'compiler' ) ,
26
+ web : resolveVue ( 'platforms/web' ) ,
27
+ core : resolveVue ( 'core' ) ,
28
+ shared : resolveVue ( 'shared' ) ,
29
+ sfc : resolveVue ( 'sfc' ) ,
30
+ //he: path.resolve(__dirname, 'node_modules', 'he', 'he')
31
+ he : path . resolve ( __dirname , '..' , 'platform/nativescript/util/entity-decoder' )
31
32
}
32
33
33
34
const builds = {
34
- 'nativescript-vue' : {
35
- entry : './platform/nativescript/framework.js' ,
36
- dest : './dist/index.js' ,
37
- moduleName : 'NativeScript-Vue' ,
38
- banner : banner ( 'NativeScript-Vue' ) ,
39
- external ( id ) {
40
- return id . startsWith ( 'ui/' ) || id . startsWith ( 'application' )
35
+ 'nativescript-vue' : {
36
+ entry : './platform/nativescript/framework.js' ,
37
+ dest : './dist/index.js' ,
38
+ moduleName : 'NativeScript-Vue' ,
39
+ banner : banner ( 'NativeScript-Vue' ) ,
40
+ external ( id ) {
41
+ return id . startsWith ( 'ui/' ) || id . startsWith ( 'application' )
42
+ }
43
+ } ,
44
+ 'nativescript-vue-template-compiler' : {
45
+ entry : './platform/nativescript/compiler.js' ,
46
+ dest : './packages/nativescript-vue-template-compiler/index.js' ,
47
+ moduleName : 'NativeScript-Vue-Template-Compiler' ,
48
+ banner : banner ( 'NativeScript-Vue-Template-Compiler' ) ,
49
+ external : Object . keys ( require ( '../packages/nativescript-vue-template-compiler/package.json' ) . dependencies )
41
50
}
42
- } ,
43
- 'nativescript-vue-template-compiler' : {
44
- entry : './platform/nativescript/compiler.js' ,
45
- dest : './packages/nativescript-vue-template-compiler/index.js' ,
46
- moduleName : 'NativeScript-Vue-Template-Compiler' ,
47
- banner : banner ( 'NativeScript-Vue-Template-Compiler' ) ,
48
- external : Object . keys ( require ( '../packages/nativescript-vue-template-compiler/package.json' ) . dependencies )
49
- }
50
51
}
51
52
52
53
53
54
const genConfig = ( name ) => {
54
- const opts = builds [ name ]
55
- const config = {
56
- input : opts . entry ,
57
- external : opts . external ,
58
- output : {
59
- file : opts . dest ,
60
- format : opts . format || 'cjs' ,
61
- banner : opts . banner ,
62
- name : opts . moduleName
63
- } ,
64
- plugins : [
65
- replace ( {
66
- __WEEX__ : false ,
67
- __VERSION__ : VueVersion ,
68
- 'process.env.NODE_ENV' : "'development'" ,
69
- 'let _isServer' : 'let _isServer = false' ,
70
- 'process.env.VUE_VERSION' : `'${ VueVersion } '` ,
71
- 'process.env.NS_VUE_VERSION' : `'${ NSVueVersion } '`
72
- } ) ,
73
- flow ( ) ,
74
- buble ( ) ,
75
- alias ( aliases ) ,
76
- commonjs ( {
77
- include : [
78
- path . resolve ( __dirname , 'node_modules' , 'vue' ) + '/**' ,
79
- //path.resolve(__dirname, 'node_modules', 'he') + '/**',
55
+ const opts = builds [ name ]
56
+ const config = {
57
+ input : opts . entry ,
58
+ external : opts . external ,
59
+ output : {
60
+ file : opts . dest ,
61
+ format : opts . format || 'cjs' ,
62
+ banner : opts . banner ,
63
+ name : opts . moduleName
64
+ } ,
65
+ plugins : [
66
+ replace ( {
67
+ __WEEX__ : false ,
68
+ __VERSION__ : VueVersion ,
69
+ 'process.env.NODE_ENV' : "'development'" ,
70
+ 'let _isServer' : 'let _isServer = false' ,
71
+ 'process.env.VUE_VERSION' : `'${ VueVersion } '` ,
72
+ 'process.env.NS_VUE_VERSION' : `'${ NSVueVersion } '`
73
+ } ) ,
74
+ flow ( ) ,
75
+ buble ( ) ,
76
+ alias ( aliases ) ,
77
+ resolve ( ) ,
78
+ commonjs ( ) ,
80
79
] ,
80
+ }
81
81
82
- namedExports : {
83
- 'he' : [ 'decode' ]
84
- }
85
- } ) ,
86
- ] ,
87
- }
88
-
89
- Object . defineProperty ( config , '_name' , {
90
- enumerable : false ,
91
- value : name
92
- } )
82
+ Object . defineProperty ( config , '_name' , {
83
+ enumerable : false ,
84
+ value : name
85
+ } )
93
86
94
- return config ;
87
+ return config ;
95
88
}
96
89
97
90
if ( process . env . TARGET ) {
98
- module . exports = genConfig ( process . env . TARGET )
91
+ module . exports = genConfig ( process . env . TARGET )
99
92
} else {
100
- module . exports . getAllBuilds = ( ) => Object . keys ( builds ) . map ( genConfig )
93
+ module . exports . getAllBuilds = ( ) => Object . keys ( builds ) . map ( genConfig )
101
94
}
0 commit comments