ns before migrate
This commit is contained in:
parent
b22669fc63
commit
4a45529a13
12 changed files with 3361 additions and 36417 deletions
21566
.update_backup/package-lock.json
generated
21566
.update_backup/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,43 +0,0 @@
|
|||
{
|
||||
"name": "enrecipes",
|
||||
"version": "1.0.0",
|
||||
"description": "A native application built with NativeScript-Vue",
|
||||
"homepage": "https://enrecipes.vercel.app/",
|
||||
"bugs": {
|
||||
"url": "https://github.com/vishnuraghavb/EnRecipes/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vishnuraghavb/EnRecipes.git"
|
||||
},
|
||||
"license": "GPL",
|
||||
"author": "Vishnu Raghav <apps@vishnuraghav.com>",
|
||||
"main": "main",
|
||||
"dependencies": {
|
||||
"@nativescript-community/perms": "^2.1.5",
|
||||
"@nativescript-community/ui-collectionview": "^4.0.29",
|
||||
"@nativescript/core": "7.3.0",
|
||||
"@nativescript/localize": "^5.0.4",
|
||||
"@nativescript/social-share": "^2.0.4",
|
||||
"@nativescript/zip": "^5.0.0",
|
||||
"@triniwiz/nativescript-accelerometer": "^4.0.3",
|
||||
"@triniwiz/nativescript-couchbase": "^1.2.2",
|
||||
"nativescript-imagecropper": "^4.0.1",
|
||||
"nativescript-intl": "^4.0.2",
|
||||
"nativescript-plugin-filepicker": "^1.0.0",
|
||||
"nativescript-toast": "^2.0.0",
|
||||
"nativescript-vue": "^2.8.4",
|
||||
"vuex": "^3.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/preset-env": "^7.12.11",
|
||||
"@nativescript/android": "7.0.1",
|
||||
"@nativescript/webpack": "4.1.0",
|
||||
"@types/node": "^14.14.20",
|
||||
"babel-loader": "^8.2.2",
|
||||
"nativescript-vue-template-compiler": "^2.8.3",
|
||||
"node-sass": "^4.14.1",
|
||||
"vue-loader": "^15.9.6"
|
||||
}
|
||||
}
|
|
@ -1,357 +0,0 @@
|
|||
const { join, relative, resolve, sep } = require('path');
|
||||
|
||||
const webpack = require('webpack');
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
|
||||
const VueLoaderPlugin = require('vue-loader/lib/plugin');
|
||||
const NsVueTemplateCompiler = require('nativescript-vue-template-compiler');
|
||||
|
||||
const nsWebpack = require('@nativescript/webpack');
|
||||
const nativescriptTarget = require('@nativescript/webpack/nativescript-target');
|
||||
const { NativeScriptWorkerPlugin } = require('nativescript-worker-loader/NativeScriptWorkerPlugin');
|
||||
const hashSalt = Date.now().toString();
|
||||
|
||||
module.exports = (env) => {
|
||||
const platform = env && ((env.android && 'android') || (env.ios && 'ios') || env.platform);
|
||||
if (!platform) {
|
||||
throw new Error('You need to provide a target platform!');
|
||||
}
|
||||
|
||||
const platforms = ['ios', 'android'];
|
||||
const projectRoot = __dirname;
|
||||
|
||||
if (env.platform) {
|
||||
platforms.push(env.platform);
|
||||
}
|
||||
|
||||
// Default destination inside platforms/<platform>/...
|
||||
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));
|
||||
|
||||
const {
|
||||
// The 'appPath' and 'appResourcesPath' values are fetched from
|
||||
// the nsconfig.json configuration file.
|
||||
appPath = 'app',
|
||||
appResourcesPath = 'app/App_Resources',
|
||||
|
||||
// You can provide the following flags when running 'tns run android|ios'
|
||||
snapshot, // --env.snapshot
|
||||
production, // --env.production
|
||||
report, // --env.report
|
||||
hmr, // --env.hmr
|
||||
sourceMap, // --env.sourceMap
|
||||
hiddenSourceMap, // --env.hiddenSourceMap
|
||||
unitTesting, // --env.unitTesting
|
||||
testing, // --env.testing
|
||||
verbose, // --env.verbose
|
||||
ci, // --env.ci
|
||||
snapshotInDocker, // --env.snapshotInDocker
|
||||
skipSnapshotTools, // --env.skipSnapshotTools
|
||||
compileSnapshot, // --env.compileSnapshot
|
||||
appComponents = [],
|
||||
entries = {},
|
||||
} = env;
|
||||
|
||||
const useLibs = compileSnapshot;
|
||||
const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
|
||||
const externals = nsWebpack.getConvertedExternals(env.externals);
|
||||
|
||||
const mode = production ? 'production' : 'development';
|
||||
|
||||
const appFullPath = resolve(projectRoot, appPath);
|
||||
const hasRootLevelScopedModules = nsWebpack.hasRootLevelScopedModules({ projectDir: projectRoot });
|
||||
let coreModulesPackageName = 'tns-core-modules';
|
||||
const alias = env.alias || {};
|
||||
alias['~/package.json'] = resolve(projectRoot, 'package.json');
|
||||
alias['~'] = appFullPath;
|
||||
alias['@'] = appFullPath;
|
||||
alias['vue'] = 'nativescript-vue';
|
||||
|
||||
if (hasRootLevelScopedModules) {
|
||||
coreModulesPackageName = '@nativescript/core';
|
||||
alias['tns-core-modules'] = coreModulesPackageName;
|
||||
}
|
||||
|
||||
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
|
||||
|
||||
const copyIgnore = { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] };
|
||||
|
||||
const entryModule = nsWebpack.getEntryModule(appFullPath, platform);
|
||||
const entryPath = `.${sep}${entryModule}`;
|
||||
Object.assign(entries, { bundle: entryPath }, entries);
|
||||
|
||||
const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some((e) => e.indexOf('@nativescript') > -1);
|
||||
if (platform === 'ios' && !areCoreModulesExternal && !testing) {
|
||||
entries['tns_modules/inspector_modules'] = '@nativescript/core/inspector_modules';
|
||||
}
|
||||
console.log(`Bundling application for entryPath ${entryPath}...`);
|
||||
|
||||
let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);
|
||||
|
||||
const itemsToClean = [`${dist}/**/*`];
|
||||
if (platform === 'android') {
|
||||
itemsToClean.push(`${join(projectRoot, 'platforms', 'android', 'app', 'src', 'main', 'assets', 'snapshots')}`);
|
||||
itemsToClean.push(`${join(projectRoot, 'platforms', 'android', 'app', 'build', 'configurations', 'nativescript-android-snapshot')}`);
|
||||
}
|
||||
|
||||
// Add your custom Activities, Services and other android app components here.
|
||||
appComponents.push('@nativescript/core/ui/frame', '@nativescript/core/ui/frame/activity');
|
||||
|
||||
nsWebpack.processAppComponents(appComponents, platform);
|
||||
const config = {
|
||||
mode: mode,
|
||||
context: appFullPath,
|
||||
externals,
|
||||
watchOptions: {
|
||||
ignored: [
|
||||
appResourcesFullPath,
|
||||
// Don't watch hidden files
|
||||
'**/.*',
|
||||
],
|
||||
},
|
||||
target: nativescriptTarget,
|
||||
// target: nativeScriptVueTarget,
|
||||
entry: entries,
|
||||
output: {
|
||||
pathinfo: false,
|
||||
path: dist,
|
||||
sourceMapFilename,
|
||||
libraryTarget: 'commonjs2',
|
||||
filename: '[name].js',
|
||||
globalObject: 'global',
|
||||
hashSalt,
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.vue', '.ts', '.js', '.scss', '.css'],
|
||||
// Resolve {N} system modules from @nativescript/core
|
||||
modules: [resolve(__dirname, `node_modules/${coreModulesPackageName}`), resolve(__dirname, 'node_modules'), `node_modules/${coreModulesPackageName}`, 'node_modules'],
|
||||
alias,
|
||||
// resolve symlinks to symlinked modules
|
||||
symlinks: true,
|
||||
},
|
||||
resolveLoader: {
|
||||
// don't resolve symlinks to symlinked loaders
|
||||
symlinks: false,
|
||||
},
|
||||
node: {
|
||||
// Disable node shims that conflict with NativeScript
|
||||
http: false,
|
||||
timers: false,
|
||||
setImmediate: false,
|
||||
fs: 'empty',
|
||||
__dirname: false,
|
||||
},
|
||||
devtool: hiddenSourceMap ? 'hidden-source-map' : sourceMap ? 'inline-source-map' : 'none',
|
||||
optimization: {
|
||||
runtimeChunk: 'single',
|
||||
noEmitOnErrors: true,
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
vendor: {
|
||||
name: 'vendor',
|
||||
chunks: 'all',
|
||||
test: (module) => {
|
||||
const moduleName = module.nameForCondition ? module.nameForCondition() : '';
|
||||
return /[\\/]node_modules[\\/]/.test(moduleName) || appComponents.some((comp) => comp === moduleName);
|
||||
},
|
||||
enforce: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
minimize: Boolean(production),
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
parallel: true,
|
||||
cache: !ci,
|
||||
sourceMap: isAnySourceMapEnabled,
|
||||
terserOptions: {
|
||||
output: {
|
||||
comments: false,
|
||||
semicolons: !isAnySourceMapEnabled,
|
||||
},
|
||||
compress: {
|
||||
// The Android SBG has problems parsing the output
|
||||
// when these options are enabled
|
||||
collapse_vars: platform !== 'android',
|
||||
sequences: platform !== 'android',
|
||||
// For v8 Compatibility
|
||||
keep_infinity: true, // for V8
|
||||
reduce_funcs: false, // for V8
|
||||
// custom
|
||||
drop_console: production,
|
||||
drop_debugger: true,
|
||||
global_defs: {
|
||||
__UGLIFIED__: true,
|
||||
},
|
||||
},
|
||||
keep_fnames: true,
|
||||
// Required for Element Level CSS, Observable Events, & Android Frame
|
||||
keep_classnames: true,
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
include: [join(appFullPath, entryPath + '.js'), join(appFullPath, entryPath + '.ts')],
|
||||
use: [
|
||||
// Require all Android app components
|
||||
platform === 'android' && {
|
||||
loader: '@nativescript/webpack/helpers/android-app-components-loader',
|
||||
options: { modules: appComponents },
|
||||
},
|
||||
|
||||
{
|
||||
loader: '@nativescript/webpack/bundle-config-loader',
|
||||
options: {
|
||||
registerPages: true, // applicable only for non-angular apps
|
||||
loadCss: !snapshot, // load the application css if in debug mode
|
||||
unitTesting,
|
||||
appFullPath,
|
||||
projectRoot,
|
||||
ignoredFiles: nsWebpack.getUserDefinedEntries(entries, platform),
|
||||
},
|
||||
},
|
||||
].filter((loader) => Boolean(loader)),
|
||||
},
|
||||
{
|
||||
test: /[\/|\\]app\.css$/,
|
||||
use: [
|
||||
'@nativescript/webpack/helpers/style-hot-loader',
|
||||
{
|
||||
loader: '@nativescript/webpack/helpers/css2json-loader',
|
||||
options: { useForImports: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /[\/|\\]app\.scss$/,
|
||||
use: [
|
||||
'@nativescript/webpack/helpers/style-hot-loader',
|
||||
{
|
||||
loader: '@nativescript/webpack/helpers/css2json-loader',
|
||||
options: { useForImports: true },
|
||||
},
|
||||
'sass-loader',
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
exclude: /[\/|\\]app\.css$/,
|
||||
use: ['@nativescript/webpack/helpers/style-hot-loader', '@nativescript/webpack/helpers/apply-css-loader.js', { loader: 'css-loader', options: { url: false } }],
|
||||
},
|
||||
{
|
||||
test: /\.scss$/,
|
||||
exclude: /[\/|\\]app\.scss$/,
|
||||
use: ['@nativescript/webpack/helpers/style-hot-loader', '@nativescript/webpack/helpers/apply-css-loader.js', { loader: 'css-loader', options: { url: false } }, 'sass-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: 'babel-loader',
|
||||
},
|
||||
{
|
||||
test: /\.ts$/,
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
appendTsSuffixTo: [/\.vue$/],
|
||||
allowTsInNodeModules: true,
|
||||
compilerOptions: {
|
||||
declaration: false,
|
||||
},
|
||||
getCustomTransformers: (program) => ({
|
||||
before: [require('@nativescript/webpack/transformers/ns-transform-native-classes').default],
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.vue$/,
|
||||
loader: 'vue-loader',
|
||||
options: {
|
||||
compiler: NsVueTemplateCompiler,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
// ... Vue Loader plugin omitted
|
||||
// make sure to include the plugin!
|
||||
new VueLoaderPlugin(),
|
||||
// Define useful constants like TNS_WEBPACK
|
||||
new webpack.DefinePlugin({
|
||||
'global.TNS_WEBPACK': 'true',
|
||||
'global.isAndroid': platform === 'android',
|
||||
'global.isIOS': platform === 'ios',
|
||||
TNS_ENV: JSON.stringify(mode),
|
||||
process: 'global.process',
|
||||
}),
|
||||
// Remove all files from the out dir.
|
||||
new CleanWebpackPlugin({
|
||||
cleanOnceBeforeBuildPatterns: itemsToClean,
|
||||
verbose: !!verbose,
|
||||
}),
|
||||
// Copy assets
|
||||
new CopyWebpackPlugin([{ from: { glob: 'assets/**', dot: false } }, { from: { glob: 'fonts/**', dot: false } }, { from: { glob: '**/*.jpg', dot: false } }, { from: { glob: '**/*.png', dot: false } }], copyIgnore),
|
||||
new nsWebpack.GenerateNativeScriptEntryPointsPlugin('bundle'),
|
||||
// For instructions on how to set up workers with webpack
|
||||
// check out https://github.com/nativescript/worker-loader
|
||||
new NativeScriptWorkerPlugin(),
|
||||
new nsWebpack.PlatformFSPlugin({
|
||||
platform,
|
||||
platforms,
|
||||
}),
|
||||
// Does IPC communication with the {N} CLI to notify events when running in watch mode.
|
||||
new nsWebpack.WatchStateLoggerPlugin(),
|
||||
],
|
||||
};
|
||||
|
||||
if (unitTesting) {
|
||||
config.module.rules.push(
|
||||
{
|
||||
test: /-page\.js$/,
|
||||
use: '@nativescript/webpack/helpers/script-hot-loader',
|
||||
},
|
||||
{
|
||||
test: /\.(html|xml)$/,
|
||||
use: '@nativescript/webpack/helpers/markup-hot-loader',
|
||||
},
|
||||
|
||||
{ test: /\.(html|xml)$/, use: '@nativescript/webpack/helpers/xml-namespace-loader' }
|
||||
);
|
||||
}
|
||||
|
||||
if (report) {
|
||||
// Generate report files for bundles content
|
||||
config.plugins.push(
|
||||
new BundleAnalyzerPlugin({
|
||||
analyzerMode: 'static',
|
||||
openAnalyzer: false,
|
||||
generateStatsFile: true,
|
||||
reportFilename: resolve(projectRoot, 'report', `report.html`),
|
||||
statsFilename: resolve(projectRoot, 'report', `stats.json`),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (snapshot) {
|
||||
config.plugins.push(
|
||||
new nsWebpack.NativeScriptSnapshotPlugin({
|
||||
chunk: 'vendor',
|
||||
requireModules: ['@nativescript/core/bundle-entry-points'],
|
||||
projectRoot,
|
||||
webpackConfig: config,
|
||||
snapshotInDocker,
|
||||
skipSnapshotTools,
|
||||
useLibs,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (hmr) {
|
||||
config.plugins.push(new webpack.HotModuleReplacementPlugin());
|
||||
}
|
||||
|
||||
return config;
|
||||
};
|
|
@ -301,7 +301,6 @@ import {
|
|||
Observable,
|
||||
} from "@nativescript/core";
|
||||
import * as Permissions from "@nativescript-community/perms";
|
||||
import * as Toast from "nativescript-toast";
|
||||
import * as Filepicker from "nativescript-plugin-filepicker";
|
||||
import { ImageCropper } from "nativescript-imagecropper";
|
||||
import { localize } from "@nativescript/localize";
|
||||
|
@ -814,7 +813,7 @@ export default {
|
|||
);
|
||||
break;
|
||||
case "denied":
|
||||
Toast.makeText(localize("dend")).show();
|
||||
// Toast.makeText(localize("dend")).show();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -50,7 +50,6 @@ import {
|
|||
} from "@nativescript/core";
|
||||
import * as Permissions from "@nativescript-community/perms";
|
||||
import { Zip } from "@nativescript/zip";
|
||||
import * as Toast from "nativescript-toast";
|
||||
import * as Filepicker from "nativescript-plugin-filepicker";
|
||||
import { localize } from "@nativescript/localize";
|
||||
import ConfirmDialog from "../modal/ConfirmDialog.vue";
|
||||
|
@ -109,7 +108,7 @@ export default {
|
|||
// EXPORT HANDLERS
|
||||
exportCheck() {
|
||||
if (!this.recipes.length) {
|
||||
Toast.makeText(localize("aFBu")).show();
|
||||
// Toast.makeText(localize("aFBu")).show();
|
||||
} else {
|
||||
this.permissionCheck(
|
||||
this.permissionConfirmation,
|
||||
|
@ -147,10 +146,10 @@ export default {
|
|||
this.backupProgress = progress;
|
||||
},
|
||||
}).then((success) => {
|
||||
Toast.makeText(
|
||||
"Backup file successfully saved to Download folder",
|
||||
"long"
|
||||
).show();
|
||||
// Toast.makeText(
|
||||
// "Backup file successfully saved to Download folder",
|
||||
// "long"
|
||||
// ).show();
|
||||
this.exportFiles("delete");
|
||||
setTimeout((e) => (this.backupInProgress = false), 3000);
|
||||
});
|
||||
|
@ -222,7 +221,7 @@ export default {
|
|||
})
|
||||
.present()
|
||||
.then((selection) => {
|
||||
Toast.makeText(localize("vrfy") + "...").show();
|
||||
// Toast.makeText(localize("vrfy") + "...").show();
|
||||
let zipPath = selection[0];
|
||||
this.validateZipContent(zipPath);
|
||||
});
|
||||
|
@ -412,7 +411,7 @@ export default {
|
|||
if (status === "authorized") action();
|
||||
if (status !== "denied")
|
||||
ApplicationSettings.setBoolean("storagePermissionAsked", true);
|
||||
else Toast.makeText(localize("dend")).show();
|
||||
// else Toast.makeText(localize("dend")).show();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
import { ApplicationSettings, Observable } from "@nativescript/core";
|
||||
import { localize } from "@nativescript/localize";
|
||||
import { mapState, mapActions } from "vuex";
|
||||
import * as Toast from "nativescript-toast";
|
||||
import * as utils from "~/shared/utils";
|
||||
|
||||
export default {
|
||||
|
@ -78,7 +77,7 @@ export default {
|
|||
let checked = args.object.checked;
|
||||
if (checked && !utils.hasAccelerometer()) {
|
||||
args.object.checked = false;
|
||||
Toast.makeText(localize("noAccSensor"), "long").show();
|
||||
// Toast.makeText(localize("noAccSensor"), "long").show();
|
||||
} else {
|
||||
ApplicationSettings.setBoolean("shakeEnabled", checked);
|
||||
this.setShakeAction(checked);
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
<script>
|
||||
import { Observable } from "@nativescript/core";
|
||||
import { localize } from "@nativescript/localize";
|
||||
import * as Toast from "nativescript-toast";
|
||||
import { mapState, mapActions } from "vuex";
|
||||
|
||||
export default {
|
||||
|
@ -77,7 +76,7 @@ export default {
|
|||
// RESET
|
||||
resetListItems(listName) {
|
||||
this.resetListItemsAction(listName);
|
||||
Toast.makeText(localize("restDone")).show();
|
||||
// Toast.makeText(localize("restDone")).show();
|
||||
},
|
||||
touch({ object, action }, type) {
|
||||
object.className = action.match(/down|move/) ? "option fade" : "option";
|
||||
|
|
|
@ -2,11 +2,10 @@ import { NativeScriptConfig } from "@nativescript/core"
|
|||
|
||||
export default {
|
||||
id: "com.vishnuraghav.enrecipes",
|
||||
appPath: "app",
|
||||
appResourcesPath: "app/resources",
|
||||
android: {
|
||||
v8Flags: "--expose_gc",
|
||||
markingMode: "none",
|
||||
codeCache: true,
|
||||
}
|
||||
// appPath: "app",
|
||||
} as NativeScriptConfig
|
||||
|
|
17338
package-lock.json
generated
17338
package-lock.json
generated
File diff suppressed because it is too large
Load diff
20
package.json
20
package.json
|
@ -12,11 +12,11 @@
|
|||
},
|
||||
"license": "GPL",
|
||||
"author": "Vishnu Raghav <apps@vishnuraghav.com>",
|
||||
"main": "main",
|
||||
"main": "app/main.js",
|
||||
"dependencies": {
|
||||
"@nativescript-community/perms": "^2.1.5",
|
||||
"@nativescript-community/ui-collectionview": "^4.0.29",
|
||||
"@nativescript/core": "8.0.0",
|
||||
"@nativescript/core": "~8.0.0",
|
||||
"@nativescript/localize": "^5.0.4",
|
||||
"@nativescript/social-share": "^2.0.4",
|
||||
"@nativescript/zip": "^5.0.0",
|
||||
|
@ -25,19 +25,17 @@
|
|||
"nativescript-imagecropper": "^4.0.1",
|
||||
"nativescript-intl": "^4.0.2",
|
||||
"nativescript-plugin-filepicker": "^1.0.0",
|
||||
"nativescript-toast": "^2.0.0",
|
||||
"nativescript-vue": "^2.8.4",
|
||||
"vuex": "^3.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/preset-env": "^7.12.11",
|
||||
"@babel/core": "~7.1.0",
|
||||
"@babel/preset-env": "~7.1.0",
|
||||
"@nativescript/android": "8.0.0",
|
||||
"@nativescript/webpack": "4.1.0",
|
||||
"@types/node": "^14.14.20",
|
||||
"babel-loader": "^8.2.2",
|
||||
"nativescript-vue-template-compiler": "^2.8.3",
|
||||
"node-sass": "^4.14.1",
|
||||
"vue-loader": "^15.9.6"
|
||||
"@nativescript/webpack": "5.0.0-beta.0",
|
||||
"babel-loader": "~8.0.0",
|
||||
"nativescript-vue-template-compiler": "^2.8.4",
|
||||
"sass": "^1.32.8",
|
||||
"vue-loader": "~15.9.6"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
||||
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
// "outDir": "./", /* Redirect output structure to the directory. */
|
||||
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||
// "removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
|
||||
/* Additional Checks */
|
||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
|
||||
/* Module Resolution Options */
|
||||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
|
||||
/* Source Map Options */
|
||||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||
|
||||
/* Experimental Options */
|
||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||
|
||||
/* Advanced Options */
|
||||
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||
}
|
||||
}
|
|
@ -1,357 +1,11 @@
|
|||
const { join, relative, resolve, sep } = require('path');
|
||||
|
||||
const webpack = require('webpack');
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
|
||||
const VueLoaderPlugin = require('vue-loader/lib/plugin');
|
||||
const NsVueTemplateCompiler = require('nativescript-vue-template-compiler');
|
||||
|
||||
const nsWebpack = require('@nativescript/webpack');
|
||||
const nativescriptTarget = require('@nativescript/webpack/nativescript-target');
|
||||
const { NativeScriptWorkerPlugin } = require('nativescript-worker-loader/NativeScriptWorkerPlugin');
|
||||
const hashSalt = Date.now().toString();
|
||||
const webpack = require("@nativescript/webpack");
|
||||
|
||||
module.exports = (env) => {
|
||||
const platform = env && ((env.android && 'android') || (env.ios && 'ios') || env.platform);
|
||||
if (!platform) {
|
||||
throw new Error('You need to provide a target platform!');
|
||||
}
|
||||
webpack.init(env);
|
||||
|
||||
const platforms = ['ios', 'android'];
|
||||
const projectRoot = __dirname;
|
||||
// todo: comments for common usage
|
||||
|
||||
if (env.platform) {
|
||||
platforms.push(env.platform);
|
||||
}
|
||||
|
||||
// Default destination inside platforms/<platform>/...
|
||||
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));
|
||||
|
||||
const {
|
||||
// The 'appPath' and 'appResourcesPath' values are fetched from
|
||||
// the nsconfig.json configuration file.
|
||||
appPath = 'app',
|
||||
appResourcesPath = 'app/App_Resources',
|
||||
|
||||
// You can provide the following flags when running 'tns run android|ios'
|
||||
snapshot, // --env.snapshot
|
||||
production, // --env.production
|
||||
report, // --env.report
|
||||
hmr, // --env.hmr
|
||||
sourceMap, // --env.sourceMap
|
||||
hiddenSourceMap, // --env.hiddenSourceMap
|
||||
unitTesting, // --env.unitTesting
|
||||
testing, // --env.testing
|
||||
verbose, // --env.verbose
|
||||
ci, // --env.ci
|
||||
snapshotInDocker, // --env.snapshotInDocker
|
||||
skipSnapshotTools, // --env.skipSnapshotTools
|
||||
compileSnapshot, // --env.compileSnapshot
|
||||
appComponents = [],
|
||||
entries = {},
|
||||
} = env;
|
||||
|
||||
const useLibs = compileSnapshot;
|
||||
const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
|
||||
const externals = nsWebpack.getConvertedExternals(env.externals);
|
||||
|
||||
const mode = production ? 'production' : 'development';
|
||||
|
||||
const appFullPath = resolve(projectRoot, appPath);
|
||||
const hasRootLevelScopedModules = nsWebpack.hasRootLevelScopedModules({ projectDir: projectRoot });
|
||||
let coreModulesPackageName = 'tns-core-modules';
|
||||
const alias = env.alias || {};
|
||||
alias['~/package.json'] = resolve(projectRoot, 'package.json');
|
||||
alias['~'] = appFullPath;
|
||||
alias['@'] = appFullPath;
|
||||
alias['vue'] = 'nativescript-vue';
|
||||
|
||||
if (hasRootLevelScopedModules) {
|
||||
coreModulesPackageName = '@nativescript/core';
|
||||
alias['tns-core-modules'] = coreModulesPackageName;
|
||||
}
|
||||
|
||||
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
|
||||
|
||||
const copyIgnore = { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] };
|
||||
|
||||
const entryModule = nsWebpack.getEntryModule(appFullPath, platform);
|
||||
const entryPath = `.${sep}${entryModule}`;
|
||||
Object.assign(entries, { bundle: entryPath }, entries);
|
||||
|
||||
const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some((e) => e.indexOf('@nativescript') > -1);
|
||||
if (platform === 'ios' && !areCoreModulesExternal && !testing) {
|
||||
entries['tns_modules/inspector_modules'] = '@nativescript/core/inspector_modules';
|
||||
}
|
||||
console.log(`Bundling application for entryPath ${entryPath}...`);
|
||||
|
||||
let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);
|
||||
|
||||
const itemsToClean = [`${dist}/**/*`];
|
||||
if (platform === 'android') {
|
||||
itemsToClean.push(`${join(projectRoot, 'platforms', 'android', 'app', 'src', 'main', 'assets', 'snapshots')}`);
|
||||
itemsToClean.push(`${join(projectRoot, 'platforms', 'android', 'app', 'build', 'configurations', 'nativescript-android-snapshot')}`);
|
||||
}
|
||||
|
||||
// Add your custom Activities, Services and other android app components here.
|
||||
appComponents.push('@nativescript/core/ui/frame', '@nativescript/core/ui/frame/activity');
|
||||
|
||||
nsWebpack.processAppComponents(appComponents, platform);
|
||||
const config = {
|
||||
mode: mode,
|
||||
context: appFullPath,
|
||||
externals,
|
||||
watchOptions: {
|
||||
ignored: [
|
||||
appResourcesFullPath,
|
||||
// Don't watch hidden files
|
||||
'**/.*',
|
||||
],
|
||||
},
|
||||
target: nativescriptTarget,
|
||||
// target: nativeScriptVueTarget,
|
||||
entry: entries,
|
||||
output: {
|
||||
pathinfo: false,
|
||||
path: dist,
|
||||
sourceMapFilename,
|
||||
libraryTarget: 'commonjs2',
|
||||
filename: '[name].js',
|
||||
globalObject: 'global',
|
||||
hashSalt,
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.vue', '.ts', '.js', '.scss', '.css'],
|
||||
// Resolve {N} system modules from @nativescript/core
|
||||
modules: [resolve(__dirname, `node_modules/${coreModulesPackageName}`), resolve(__dirname, 'node_modules'), `node_modules/${coreModulesPackageName}`, 'node_modules'],
|
||||
alias,
|
||||
// resolve symlinks to symlinked modules
|
||||
symlinks: true,
|
||||
},
|
||||
resolveLoader: {
|
||||
// don't resolve symlinks to symlinked loaders
|
||||
symlinks: false,
|
||||
},
|
||||
node: {
|
||||
// Disable node shims that conflict with NativeScript
|
||||
http: false,
|
||||
timers: false,
|
||||
setImmediate: false,
|
||||
fs: 'empty',
|
||||
__dirname: false,
|
||||
},
|
||||
devtool: hiddenSourceMap ? 'hidden-source-map' : sourceMap ? 'inline-source-map' : 'none',
|
||||
optimization: {
|
||||
runtimeChunk: 'single',
|
||||
noEmitOnErrors: true,
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
vendor: {
|
||||
name: 'vendor',
|
||||
chunks: 'all',
|
||||
test: (module) => {
|
||||
const moduleName = module.nameForCondition ? module.nameForCondition() : '';
|
||||
return /[\\/]node_modules[\\/]/.test(moduleName) || appComponents.some((comp) => comp === moduleName);
|
||||
},
|
||||
enforce: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
minimize: Boolean(production),
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
parallel: true,
|
||||
cache: !ci,
|
||||
sourceMap: isAnySourceMapEnabled,
|
||||
terserOptions: {
|
||||
output: {
|
||||
comments: false,
|
||||
semicolons: !isAnySourceMapEnabled,
|
||||
},
|
||||
compress: {
|
||||
// The Android SBG has problems parsing the output
|
||||
// when these options are enabled
|
||||
collapse_vars: platform !== 'android',
|
||||
sequences: platform !== 'android',
|
||||
// For v8 Compatibility
|
||||
keep_infinity: true, // for V8
|
||||
reduce_funcs: false, // for V8
|
||||
// custom
|
||||
drop_console: production,
|
||||
drop_debugger: true,
|
||||
global_defs: {
|
||||
__UGLIFIED__: true,
|
||||
},
|
||||
},
|
||||
keep_fnames: true,
|
||||
// Required for Element Level CSS, Observable Events, & Android Frame
|
||||
keep_classnames: true,
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
include: [join(appFullPath, entryPath + '.js'), join(appFullPath, entryPath + '.ts')],
|
||||
use: [
|
||||
// Require all Android app components
|
||||
platform === 'android' && {
|
||||
loader: '@nativescript/webpack/helpers/android-app-components-loader',
|
||||
options: { modules: appComponents },
|
||||
},
|
||||
|
||||
{
|
||||
loader: '@nativescript/webpack/bundle-config-loader',
|
||||
options: {
|
||||
registerPages: true, // applicable only for non-angular apps
|
||||
loadCss: !snapshot, // load the application css if in debug mode
|
||||
unitTesting,
|
||||
appFullPath,
|
||||
projectRoot,
|
||||
ignoredFiles: nsWebpack.getUserDefinedEntries(entries, platform),
|
||||
},
|
||||
},
|
||||
].filter((loader) => Boolean(loader)),
|
||||
},
|
||||
{
|
||||
test: /[\/|\\]app\.css$/,
|
||||
use: [
|
||||
'@nativescript/webpack/helpers/style-hot-loader',
|
||||
{
|
||||
loader: '@nativescript/webpack/helpers/css2json-loader',
|
||||
options: { useForImports: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /[\/|\\]app\.scss$/,
|
||||
use: [
|
||||
'@nativescript/webpack/helpers/style-hot-loader',
|
||||
{
|
||||
loader: '@nativescript/webpack/helpers/css2json-loader',
|
||||
options: { useForImports: true },
|
||||
},
|
||||
'sass-loader',
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
exclude: /[\/|\\]app\.css$/,
|
||||
use: ['@nativescript/webpack/helpers/style-hot-loader', '@nativescript/webpack/helpers/apply-css-loader.js', { loader: 'css-loader', options: { url: false } }],
|
||||
},
|
||||
{
|
||||
test: /\.scss$/,
|
||||
exclude: /[\/|\\]app\.scss$/,
|
||||
use: ['@nativescript/webpack/helpers/style-hot-loader', '@nativescript/webpack/helpers/apply-css-loader.js', { loader: 'css-loader', options: { url: false } }, 'sass-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: 'babel-loader',
|
||||
},
|
||||
{
|
||||
test: /\.ts$/,
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
appendTsSuffixTo: [/\.vue$/],
|
||||
allowTsInNodeModules: true,
|
||||
compilerOptions: {
|
||||
declaration: false,
|
||||
},
|
||||
getCustomTransformers: (program) => ({
|
||||
before: [require('@nativescript/webpack/transformers/ns-transform-native-classes').default],
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.vue$/,
|
||||
loader: 'vue-loader',
|
||||
options: {
|
||||
compiler: NsVueTemplateCompiler,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
// ... Vue Loader plugin omitted
|
||||
// make sure to include the plugin!
|
||||
new VueLoaderPlugin(),
|
||||
// Define useful constants like TNS_WEBPACK
|
||||
new webpack.DefinePlugin({
|
||||
'global.TNS_WEBPACK': 'true',
|
||||
'global.isAndroid': platform === 'android',
|
||||
'global.isIOS': platform === 'ios',
|
||||
TNS_ENV: JSON.stringify(mode),
|
||||
process: 'global.process',
|
||||
}),
|
||||
// Remove all files from the out dir.
|
||||
new CleanWebpackPlugin({
|
||||
cleanOnceBeforeBuildPatterns: itemsToClean,
|
||||
verbose: !!verbose,
|
||||
}),
|
||||
// Copy assets
|
||||
new CopyWebpackPlugin([{ from: { glob: 'assets/**', dot: false } }, { from: { glob: 'fonts/**', dot: false } }, { from: { glob: '**/*.jpg', dot: false } }, { from: { glob: '**/*.png', dot: false } }], copyIgnore),
|
||||
new nsWebpack.GenerateNativeScriptEntryPointsPlugin('bundle'),
|
||||
// For instructions on how to set up workers with webpack
|
||||
// check out https://github.com/nativescript/worker-loader
|
||||
new NativeScriptWorkerPlugin(),
|
||||
new nsWebpack.PlatformFSPlugin({
|
||||
platform,
|
||||
platforms,
|
||||
}),
|
||||
// Does IPC communication with the {N} CLI to notify events when running in watch mode.
|
||||
new nsWebpack.WatchStateLoggerPlugin(),
|
||||
],
|
||||
};
|
||||
|
||||
if (unitTesting) {
|
||||
config.module.rules.push(
|
||||
{
|
||||
test: /-page\.js$/,
|
||||
use: '@nativescript/webpack/helpers/script-hot-loader',
|
||||
},
|
||||
{
|
||||
test: /\.(html|xml)$/,
|
||||
use: '@nativescript/webpack/helpers/markup-hot-loader',
|
||||
},
|
||||
|
||||
{ test: /\.(html|xml)$/, use: '@nativescript/webpack/helpers/xml-namespace-loader' }
|
||||
);
|
||||
}
|
||||
|
||||
if (report) {
|
||||
// Generate report files for bundles content
|
||||
config.plugins.push(
|
||||
new BundleAnalyzerPlugin({
|
||||
analyzerMode: 'static',
|
||||
openAnalyzer: false,
|
||||
generateStatsFile: true,
|
||||
reportFilename: resolve(projectRoot, 'report', `report.html`),
|
||||
statsFilename: resolve(projectRoot, 'report', `stats.json`),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (snapshot) {
|
||||
config.plugins.push(
|
||||
new nsWebpack.NativeScriptSnapshotPlugin({
|
||||
chunk: 'vendor',
|
||||
requireModules: ['@nativescript/core/bundle-entry-points'],
|
||||
projectRoot,
|
||||
webpackConfig: config,
|
||||
snapshotInDocker,
|
||||
skipSnapshotTools,
|
||||
useLibs,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (hmr) {
|
||||
config.plugins.push(new webpack.HotModuleReplacementPlugin());
|
||||
}
|
||||
|
||||
return config;
|
||||
return webpack.resolveConfig();
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue