Skip to content

Commit 8e6a0f0

Browse files
SupermanSuperman
authored andcommitted
update nativescript version
1 parent a25765b commit 8e6a0f0

File tree

10 files changed

+20676
-2264
lines changed

10 files changed

+20676
-2264
lines changed

.DS_Store

0 Bytes
Binary file not shown.

._.gitignore

-4 KB
Binary file not shown.

.migration_backup/package-lock.json

Lines changed: 10300 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.migration_backup/package.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "nativescript-vue-examples",
3+
"version": "1.0.0",
4+
"description": "A native application built with NativeScript-Vue",
5+
"author": "nuochong <nuo.chong@163.com>",
6+
"license": "MIT",
7+
"nativescript": {
8+
"id": "org.nativescript.application",
9+
"tns-ios": {
10+
"version": "5.2.0"
11+
},
12+
"tns-android": {
13+
"version": "5.2.0"
14+
}
15+
},
16+
"dependencies": {
17+
"@vue/devtools": "^5.0.0-beta.3",
18+
"nativescript-app-shortcuts": "^2.1.0",
19+
"nativescript-camera": "^4.5.0",
20+
"nativescript-fancyalert": "^2.0.0",
21+
"nativescript-geolocation": "^4.3.1",
22+
"nativescript-local-notifications": "^3.1.0",
23+
"nativescript-permissions": "^1.2.3",
24+
"nativescript-phone": "^1.3.1",
25+
"nativescript-pulltorefresh": "^2.2.0",
26+
"nativescript-socket.io": "^0.9.0",
27+
"nativescript-theme-core": "^1.0.4",
28+
"nativescript-toast": "^1.4.6",
29+
"nativescript-ui-sidedrawer": "^5.0.0",
30+
"nativescript-vue": "^2.0.0",
31+
"nativescript-vue-devtools": "^1.1.0",
32+
"nativescript-vue-multi-drawer": "0.0.2",
33+
"tns-core-modules": "^5.2.1",
34+
"vuex": "^3.0.1"
35+
},
36+
"devDependencies": {
37+
"@babel/core": "^7.0.0",
38+
"@babel/preset-env": "^7.0.0",
39+
"babel-loader": "^8.0.2",
40+
"babel-traverse": "6.26.0",
41+
"babel-types": "6.26.0",
42+
"babylon": "6.18.0",
43+
"clean-webpack-plugin": "^0.1.19",
44+
"copy-webpack-plugin": "^4.5.2",
45+
"css-hot-loader": "^1.4.2",
46+
"css-loader": "^1.0.0",
47+
"lazy": "1.0.11",
48+
"mini-css-extract-plugin": "^0.4.1",
49+
"nativescript-dev-webpack": "next",
50+
"nativescript-vue-template-compiler": "^2.0.0",
51+
"nativescript-worker-loader": "~0.9.0",
52+
"node-sass": "^4.9.2",
53+
"sass-loader": "^7.1.0",
54+
"uglifyjs-webpack-plugin": "~1.2.7",
55+
"terser-webpack-plugin": "^1.1.0",
56+
"vue-loader": "^15.2.6",
57+
"webpack": "^4.16.4",
58+
"webpack-bundle-analyzer": "~2.13.1",
59+
"webpack-cli": "^3.1.0"
60+
}
61+
}
Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
const { relative, resolve, sep } = require("path");
2+
3+
const webpack = require("webpack");
4+
const CleanWebpackPlugin = require("clean-webpack-plugin");
5+
const CopyWebpackPlugin = require("copy-webpack-plugin");
6+
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
7+
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
8+
9+
const VueLoaderPlugin = require('vue-loader/lib/plugin');
10+
const NsVueTemplateCompiler = require("nativescript-vue-template-compiler");
11+
12+
const nsWebpack = require("nativescript-dev-webpack");
13+
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
14+
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
15+
16+
module.exports = env => {
17+
// Add your custom Activities, Services and other android app components here.
18+
const appComponents = [
19+
"tns-core-modules/ui/frame",
20+
"tns-core-modules/ui/frame/activity",
21+
];
22+
23+
const platform = env && (env.android && "android" || env.ios && "ios");
24+
if (!platform) {
25+
throw new Error("You need to provide a target platform!");
26+
}
27+
28+
const platforms = ["ios", "android"];
29+
const projectRoot = __dirname;
30+
31+
// Default destination inside platforms/<platform>/...
32+
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));
33+
const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS";
34+
35+
const {
36+
// The 'appPath' and 'appResourcesPath' values are fetched from
37+
// the nsconfig.json configuration file
38+
// when bundling with `tns run android|ios --bundle`.
39+
appPath = "app",
40+
appResourcesPath = "app/App_Resources",
41+
42+
// You can provide the following flags when running 'tns run android|ios'
43+
snapshot, // --env.snapshot
44+
production, // --env.production
45+
report, // --env.report
46+
hmr, // --env.hmr
47+
} = env;
48+
49+
const externals = (env.externals || []).map((e) => { // --env.externals
50+
return new RegExp(e + ".*");
51+
});
52+
53+
const mode = production ? "production" : "development"
54+
55+
const appFullPath = resolve(projectRoot, appPath);
56+
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
57+
58+
const entryModule = nsWebpack.getEntryModule(appFullPath);
59+
const entryPath = `.${sep}${entryModule}.js`;
60+
console.log(`Bundling application for entryPath ${entryPath}...`);
61+
62+
const config = {
63+
mode: mode,
64+
context: appFullPath,
65+
externals,
66+
watchOptions: {
67+
ignored: [
68+
appResourcesFullPath,
69+
// Don't watch hidden files
70+
"**/.*",
71+
],
72+
},
73+
target: nativescriptTarget,
74+
// target: nativeScriptVueTarget,
75+
entry: {
76+
bundle: entryPath,
77+
},
78+
output: {
79+
pathinfo: false,
80+
path: dist,
81+
libraryTarget: "commonjs2",
82+
filename: "[name].js",
83+
globalObject: "global",
84+
},
85+
resolve: {
86+
extensions: [".vue", ".js", ".scss", ".css"],
87+
// Resolve {N} system modules from tns-core-modules
88+
modules: [
89+
resolve(__dirname, "node_modules/tns-core-modules"),
90+
resolve(__dirname, "node_modules"),
91+
"node_modules/tns-core-modules",
92+
"node_modules",
93+
],
94+
alias: {
95+
'~': appFullPath,
96+
'@': appFullPath,
97+
'vue': 'nativescript-vue'
98+
},
99+
// don't resolve symlinks to symlinked modules
100+
symlinks: false,
101+
},
102+
resolveLoader: {
103+
// don't resolve symlinks to symlinked loaders
104+
symlinks: false,
105+
},
106+
node: {
107+
// Disable node shims that conflict with NativeScript
108+
"http": false,
109+
"timers": false,
110+
"setImmediate": false,
111+
"fs": "empty",
112+
"__dirname": false,
113+
},
114+
devtool: "none",
115+
optimization: {
116+
splitChunks: {
117+
cacheGroups: {
118+
vendor: {
119+
name: "vendor",
120+
chunks: "all",
121+
test: (module) => {
122+
const moduleName = module.nameForCondition ? module.nameForCondition() : '';
123+
return /[\\/]node_modules[\\/]/.test(moduleName) ||
124+
appComponents.some(comp => comp === moduleName);
125+
126+
},
127+
enforce: true,
128+
},
129+
},
130+
},
131+
minimize: Boolean(production),
132+
minimizer: [
133+
new UglifyJsPlugin({
134+
parallel: true,
135+
cache: true,
136+
uglifyOptions: {
137+
output: {
138+
comments: false,
139+
},
140+
compress: {
141+
// The Android SBG has problems parsing the output
142+
// when these options are enabled
143+
'collapse_vars': platform !== "android",
144+
sequences: platform !== "android",
145+
},
146+
},
147+
}),
148+
],
149+
},
150+
module: {
151+
rules: [{
152+
test: new RegExp(entryPath),
153+
use: [
154+
// Require all Android app components
155+
platform === "android" && {
156+
loader: "nativescript-dev-webpack/android-app-components-loader",
157+
options: { modules: appComponents },
158+
},
159+
160+
{
161+
loader: "nativescript-dev-webpack/bundle-config-loader",
162+
options: {
163+
registerPages: true, // applicable only for non-angular apps
164+
loadCss: !snapshot, // load the application css if in debug mode
165+
},
166+
},
167+
].filter(loader => Boolean(loader)),
168+
},
169+
{
170+
test: /\.css$/,
171+
use: [
172+
'nativescript-dev-webpack/style-hot-loader',
173+
'nativescript-dev-webpack/apply-css-loader.js',
174+
{ loader: "css-loader", options: { minimize: false, url: false } },
175+
],
176+
},
177+
{
178+
test: /\.scss$/,
179+
use: [
180+
'nativescript-dev-webpack/style-hot-loader',
181+
'nativescript-dev-webpack/apply-css-loader.js',
182+
{ loader: "css-loader", options: { minimize: false, url: false } },
183+
"sass-loader",
184+
],
185+
},
186+
{
187+
test: /\.js$/,
188+
loader: 'babel-loader',
189+
},
190+
{
191+
test: /\.vue$/,
192+
loader: "vue-loader",
193+
options: {
194+
compiler: NsVueTemplateCompiler,
195+
},
196+
},
197+
],
198+
},
199+
plugins: [
200+
// ... Vue Loader plugin omitted
201+
// make sure to include the plugin!
202+
new VueLoaderPlugin(),
203+
// Define useful constants like TNS_WEBPACK
204+
new webpack.DefinePlugin({
205+
"global.TNS_WEBPACK": "true",
206+
"TNS_ENV": JSON.stringify(mode)
207+
}),
208+
// Remove all files from the out dir.
209+
new CleanWebpackPlugin([`${dist}/**/*`]),
210+
// Copy native app resources to out dir.
211+
new CopyWebpackPlugin([{
212+
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
213+
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
214+
context: projectRoot,
215+
}]),
216+
// Copy assets to out dir. Add your own globs as needed.
217+
new CopyWebpackPlugin([
218+
{ from: { glob: "fonts/**" } },
219+
{ from: { glob: "**/*.+(jpg|png)" } },
220+
{ from: { glob: "assets/**/*" } },
221+
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
222+
// Generate a bundle starter script and activate it in package.json
223+
new nsWebpack.GenerateBundleStarterPlugin([
224+
"./vendor",
225+
"./bundle",
226+
]),
227+
// For instructions on how to set up workers with webpack
228+
// check out https://github.com/nativescript/worker-loader
229+
new NativeScriptWorkerPlugin(),
230+
new nsWebpack.PlatformFSPlugin({
231+
platform,
232+
platforms,
233+
}),
234+
// Does IPC communication with the {N} CLI to notify events when running in watch mode.
235+
new nsWebpack.WatchStateLoggerPlugin(),
236+
],
237+
};
238+
239+
if (report) {
240+
// Generate report files for bundles content
241+
config.plugins.push(new BundleAnalyzerPlugin({
242+
analyzerMode: "static",
243+
openAnalyzer: false,
244+
generateStatsFile: true,
245+
reportFilename: resolve(projectRoot, "report", `report.html`),
246+
statsFilename: resolve(projectRoot, "report", `stats.json`),
247+
}));
248+
}
249+
250+
if (snapshot) {
251+
config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({
252+
chunk: "vendor",
253+
requireModules: [
254+
"tns-core-modules/bundle-entry-points",
255+
],
256+
projectRoot,
257+
webpackConfig: config,
258+
}));
259+
}
260+
261+
if (hmr) {
262+
config.plugins.push(new webpack.HotModuleReplacementPlugin());
263+
}
264+
265+
return config;
266+
};

app/main.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Vue from 'nativescript-vue';
22
import App from './components/App';
33
//import router from './router';
44
import store from './store';
5-
import { prototype } from 'stream';
65
//import VueDevtools from 'nativescript-vue-devtools'
76

87

@@ -175,10 +174,10 @@ Vue.use(Dialog, {
175174
});
176175

177176
// //下拉刷新
178-
Vue.registerElement(
179-
'PullToRefresh',
180-
() => require('nativescript-pulltorefresh').PullToRefresh
181-
);
177+
// Vue.registerElement(
178+
// 'PullToRefresh',
179+
// () => require('nativescript-pulltorefresh').PullToRefresh
180+
// );
182181

183182
new Vue({
184183
//router,

0 commit comments

Comments
 (0)