Skip to content

Commit 6b24dfc

Browse files
committed
use vue-cli service .env file pipeline for native
add dependencies at invoke fix issue with non-css preprocessor style tags
1 parent 93d55af commit 6b24dfc

18 files changed

+150
-109
lines changed

generator/index.js

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,50 +53,51 @@ module.exports = async (api, options, rootOptions) => {
5353
nativescript: {
5454
id: 'org.nativescript.application',
5555
'tns-ios': {
56-
version: '5.2.0'
56+
version: '5.2.1'
5757
},
5858
'tns-android': {
59-
version: '5.2.0'
59+
version: '5.2.1'
6060
}
6161
},
6262
scripts: {
63-
'build:android':
64-
// eslint-disable-next-line max-len
65-
'npm run setup-webpack-config && cross-env-shell VUE_CLI_MODE=production.android tns build android --bundle --env.production && npm run remove-webpack-config',
66-
'build:ios':
67-
'npm run setup-webpack-config && cross-env-shell VUE_CLI_MODE=production.ios tns build ios --bundle --env.production && npm run remove-webpack-config',
63+
'build:android': 'npm run setup-webpack-config && tns build android --bundle --env.production && npm run remove-webpack-config',
64+
'build:ios': 'npm run setup-webpack-config && tns build ios --bundle --env.production && npm run remove-webpack-config',
6865
'remove-webpack-config': 'node ./node_modules/vue-cli-plugin-nativescript-vue/lib/scripts/webpack-maintenance post',
69-
'serve:android': 'npm run setup-webpack-config && cross-env-shell VUE_CLI_MODE=development.android tns run android --bundle --env.development',
70-
'serve:ios': 'npm run setup-webpack-config && cross-env-shell VUE_CLI_MODE=development.ios tns run ios --bundle --env.development',
66+
'serve:android': 'npm run setup-webpack-config && tns run android --bundle --env.development',
67+
'serve:ios': 'npm run setup-webpack-config && tns run ios --bundle --env.development',
7168
// 'inspect:android': 'npm run setup-webpack-config && vue inspect -- --env.android > out-android.js',
7269
// 'inspect:ios': 'npm run setup-webpack-config && vue inspect -- --env.ios > out-ios.js',
73-
'debug:android': 'npm run setup-webpack-config && cross-env-shell VUE_CLI_MODE=development.android tns debug android --bundle --env.development',
74-
'debug:ios': 'npm run setup-webpack-config && cross-env-shell VUE_CLI_MODE=development.ios tns debug ios --bundle --env.development',
75-
'preview:android':
76-
'npm run setup-webpack-config && cross-env-shell VUE_CLI_MODE=development.android tns preview --bundle --env.development --env.android',
77-
'preview:ios': 'npm run setup-webpack-config && cross-env-shell VUE_CLI_MODE=development.android tns preview --bundle --env.development --env.ios',
78-
'setup-webpack-config': 'node ./node_modules/vue-cli-plugin-nativescript-vue/lib/scripts/webpack-maintenance pre'
70+
'debug:android': 'npm run setup-webpack-config && tns debug android --bundle --env.development',
71+
'debug:ios': 'npm run setup-webpack-config && tns debug ios --bundle --env.development',
72+
'preview:android': 'npm run setup-webpack-config && tns preview --bundle --env.development --env.android',
73+
'preview:ios': 'npm run setup-webpack-config && tns preview --bundle --env.development --env.ios',
74+
'setup-webpack-config': 'node ./node_modules/vue-cli-plugin-nativescript-vue/lib/scripts/webpack-maintenance pre',
75+
'clean:platforms': 'rimraf platforms',
76+
'clean:android': 'rimraf platforms/android',
77+
'clean:ios': 'rimraf platforms/ios'
7978
},
8079
dependencies: {
8180
'nativescript-vue': '^2.0.2',
8281
'tns-core-modules': '^5.2.1'
8382
},
8483
devDependencies: {
85-
'cross-env': '^5.2.0',
8684
'nativescript-dev-webpack': '^0.17.0',
8785
'nativescript-vue-template-compiler': '^2.0.2',
8886
'nativescript-worker-loader': '~0.9.1',
8987
'node-sass': '^4.11.0',
90-
'string-replace-loader': '^2.1.1'
88+
'string-replace-loader': '^2.1.1',
89+
rimraf: '^2.6.3',
90+
webpack: '^4.29.6',
91+
'webpack-cli': '^3.2.3'
9192
}
9293
});
9394

9495
// add scripts when we are also developing for the web
9596
if (!options.isNativeOnly) {
9697
api.extendPackage({
9798
scripts: {
98-
'serve:web': 'vue-cli-service serve --mode development.web --env.development --env.web',
99-
'build:web': 'vue-cli-service build --mode production.web --env.production --env.web'
99+
'serve:web': 'vue-cli-service serve --mode development.web',
100+
'build:web': 'vue-cli-service build --mode production.web'
100101
//'inspect:web': 'npm run setup-webpack-config && vue inspect -- --env.web > out-web.js'
101102
}
102103
});
@@ -252,6 +253,13 @@ module.exports = async (api, options, rootOptions) => {
252253
nativeOnlyRenameFiles(genConfig.dirPathPrefix + genConfig.nativeAppPathModifier.slice(0, -1));
253254
}
254255

256+
// remove router config for projects that don't use vue-router
257+
if (!rootOptions.router) {
258+
fs.remove(genConfig.dirPathPrefix + genConfig.nativeAppPathModifier + 'router' + genConfig.jsOrTs, (err) => {
259+
if (err) throw err;
260+
});
261+
}
262+
255263
if (api.hasPlugin('typescript')) {
256264
if (fs.existsSync(api.resolve('tslint.json'))) {
257265
require('../lib/tslint')({}, api, true);

generator/templates/nvw/src/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
<%_ } _%>
198198
<%_ } else { _%>
199199
<%# -------------------- IS Using standard CSS -------------------- -%>
200-
<style web lang="scss">
200+
<style web>
201201
@import '~styles/style-one';
202202

203203
.w-page {
@@ -209,7 +209,7 @@
209209
color: #42b983;
210210
}
211211
</style>
212-
<style native lang="scss">
212+
<style native>
213213
@import '~styles/style-one';
214214
</style>
215215
<%_ } _%>

generator/templates/nvw/src/components/HelloWorld.android.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<%_ } _%>
7979
<%_ } else { _%>
8080
<%# -------------------- IS Using standard CSS -------------------- -%>
81-
<style scoped lang="scss">
81+
<style scoped>
8282
.message {
8383
color: #42b983;
8484
}

generator/templates/nvw/src/components/HelloWorld.ios.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<%_ } _%>
7979
<%_ } else { _%>
8080
<%# -------------------- IS Using standard CSS -------------------- -%>
81-
<style scoped lang="scss">
81+
<style scoped>
8282
.message {
8383
color: #42b983;
8484
}

generator/templates/nvw/src/components/HelloWorld.native.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<%_ } _%>
7979
<%_ } else { _%>
8080
<%# -------------------- IS Using standard CSS -------------------- -%>
81-
<style scoped lang="scss">
81+
<style scoped>
8282
.message {
8383
color: #42b983;
8484
}

generator/templates/nvw/src/components/HelloWorld.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<%_ } _%>
9393
<%_ } else { _%>
9494
<%# -------------------- IS Using standard CSS -------------------- -%>
95-
<style scoped lang="scss">
95+
<style scoped>
9696
.message {
9797
color: #42b983;
9898
display: block;

generator/templates/nvw/src/views/About.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
<%_ } _%>
106106
<%_ } else { _%>
107107
<%# -------------------- IS Using standard CSS -------------------- -%>
108-
<style scoped lang="scss">
108+
<style scoped>
109109
@import '~styles/style-two';
110110
@import '~styles/style-one';
111111

generator/templates/nvw/src/views/Home.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
<%_ } _%>
123123
<%_ } else { _%>
124124
<%# -------------------- IS Using standard CSS -------------------- -%>
125-
<style scoped lang="scss">
125+
<style scoped>
126126
@import '~styles/style-one';
127127
@import '~styles/style-two';
128128

generator/templates/simple/src/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,15 @@
198198
<%_ } _%>
199199
<%_ } else { _%>
200200
<%# -------------------- IS Using standard CSS -------------------- -%>
201-
<style web lang="scss">
201+
<style web>
202202
@import '~styles/style-one';
203203

204204
.w-page {
205205
height: 100%;
206206
width: 100%;
207207
}
208208
</style>
209-
<style native lang="scss">
209+
<style native>
210210
@import '~styles/style-one';
211211
</style>
212212
<%_ } _%>

generator/templates/simple/src/components/HelloWorld.android.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<%_ } _%>
7979
<%_ } else { _%>
8080
<%# -------------------- IS Using standard CSS -------------------- -%>
81-
<style scoped lang="scss">
81+
<style scoped>
8282
.message {
8383
color: #42b983;
8484
}

0 commit comments

Comments
 (0)