Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
Hosted Weblate 2021-04-14 15:38:34 +02:00
commit 2ceba08e17
11 changed files with 188 additions and 408 deletions

View file

@ -46,15 +46,34 @@
</Page>
</template>
<script>
<script lang="ts">
import { Screen } from "@nativescript/core";
import { localize } from "@nativescript/localize";
import { mapState, mapActions } from "vuex";
import ConfirmDialog from "./ConfirmDialog.vue";
interface IData {
newList: unknown[];
stretch: boolean;
listHeight: number;
}
export default {
props: ["title", "list", "action"],
data() {
props: {
title: {
type: String,
required: true,
},
list: {
type: Array,
required: true,
},
action: {
type: String,
required: false,
},
},
data(): IData {
return {
newList: this.list,
stretch: false,
@ -66,14 +85,13 @@ export default {
},
methods: {
...mapActions(["removeListItemAction"]),
localized(item) {
if (this.title !== "lang") return localize(item);
else return item;
localized(item: string): string {
return this.title !== "lang" ? localize(item) : item;
},
tapAction(item) {
tapAction(item: string): void {
this.$modal.close(item);
},
deletionConfirmation(type, description) {
deletionConfirmation(description: string): void {
return this.$showModal(ConfirmDialog, {
props: {
title: "conf",
@ -83,14 +101,12 @@ export default {
},
});
},
removeItem(item) {
removeItem(item: string): void {
let vm = this;
function removeListItem(type, listName, desc) {
function removeListItem(listName: string, desc: string): void {
vm.deletionConfirmation(
type,
`${localize(desc)} "${localize(item)}"\n\n${localize("rmLIInfo")}`
).then((action) => {
).then((action: boolean) => {
if (action != null && action)
vm.removeListItemAction({
item,
@ -100,20 +116,20 @@ export default {
}
switch (this.title) {
case "cui":
removeListItem("cuisine", "cuisines", "rmCuiInfo");
removeListItem("cuisines", "rmCuiInfo");
break;
case "cat":
removeListItem("category", "categories", "rmCatInfo");
removeListItem("categories", "rmCatInfo");
break;
case "yieldU":
removeListItem("yield unit", "yieldUnits", "rmYUInfo");
removeListItem("yieldUnits", "rmYUInfo");
break;
case "Unit":
removeListItem("unit", "units", "rmUInfo");
removeListItem("units", "rmUInfo");
break;
}
},
touch({ object, action }) {
touch({ object, action }): void {
object.className = action.match(/down|move/)
? "listItem fade"
: "listItem";

View file

@ -31,10 +31,27 @@
</Page>
</template>
<script>
<script lang="ts">
import { mapState } from "vuex";
export default {
props: ["title", "description", "cancelButtonText", "okButtonText"],
props: {
title: {
type: String,
required: true,
},
description: {
type: String,
required: true,
},
cancelButtonText: {
type: String,
required: true,
},
okButtonText: {
type: String,
required: true,
},
},
computed: {
...mapState(["icon", "appTheme"]),
},

View file

@ -9,7 +9,7 @@ on(launchEvent, (args) => {
}
})
import Vue from 'nativescript-vue'
import EnRecipes from './components/EnRecipes'
import EnRecipes from './components/EnRecipes.vue'
import store from './store'
import CollectionView from '@nativescript-community/ui-collectionview/vue'

View file

@ -1,13 +1,8 @@
import Vue from 'vue'
import Vue from 'nativescript-vue'
import Vuex from 'vuex'
Vue.use(Vuex)
import { CouchBase } from '@triniwiz/nativescript-couchbase'
import {
Application,
getFileAccess,
File,
ApplicationSettings,
} from '@nativescript/core'
import { getFileAccess, File, ApplicationSettings } from '@nativescript/core'
const EnRecipesDB = new CouchBase('EnRecipes')
const userCuisinesDB = new CouchBase('userCuisines')
const userCategoriesDB = new CouchBase('userCategories')

View file

@ -1,10 +0,0 @@
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"~/*": ["app/*"],
"@/*": ["app/*"]
}
},
"include": ["app/**/*"]
}

105
package-lock.json generated
View file

@ -22,9 +22,13 @@
},
"devDependencies": {
"@nativescript/android": "8.0.0",
"@nativescript/types": "^8.0.0",
"@nativescript/webpack": "beta",
"@types/node": "^14.14.37",
"nativescript-vue-template-compiler": "~2.9.0",
"sass": "^1.32.8"
"sass": "^1.32.8",
"typescript": "^4.2.4",
"vue": "^2.6.12"
}
},
"node_modules/@babel/code-frame": {
@ -408,6 +412,28 @@
"sprintf-js": "^1.1.1"
}
},
"node_modules/@nativescript/types": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/@nativescript/types/-/types-8.0.0.tgz",
"integrity": "sha512-xfVLHZ4L0T7/Y4v+BBmH+GBvYRqYtasi8YaG4QV5oZPLKu2sBGjQkhME3ghx/FTh+0QRwMbSU8FJKkyK35rR3A==",
"dev": true,
"dependencies": {
"@nativescript/types-android": "8.0.0",
"@nativescript/types-ios": "8.0.0"
}
},
"node_modules/@nativescript/types-android": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/@nativescript/types-android/-/types-android-8.0.0.tgz",
"integrity": "sha512-4b/RHhXjX/KLLNLiuCCOWNFnXhK5/3+mGkO/eXJbY1DbCDol4Fv8hbpRHridrhwihZAvqE0rVi5RlLFCtS2TBg==",
"dev": true
},
"node_modules/@nativescript/types-ios": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/@nativescript/types-ios/-/types-ios-8.0.0.tgz",
"integrity": "sha512-QarxaXGN+T+33kDC+FtIY1b3xgHHfJODtXqbTQJxxV4HPiCx8dEDTT746xkQtH8j1F/92Q3oY4h0B5HhJS0QvQ==",
"dev": true
},
"node_modules/@nativescript/webpack": {
"version": "5.0.0-beta.6",
"resolved": "https://registry.npmjs.org/@nativescript/webpack/-/webpack-5.0.0-beta.6.tgz",
@ -1818,9 +1844,9 @@
"dev": true
},
"node_modules/electron-to-chromium": {
"version": "1.3.713",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.713.tgz",
"integrity": "sha512-HWgkyX4xTHmxcWWlvv7a87RHSINEcpKYZmDMxkUlHcY+CJcfx7xEfBHuXVsO1rzyYs1WQJ7EgDp2CoErakBIow==",
"version": "1.3.716",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.716.tgz",
"integrity": "sha512-yUWKAfpJH5ovgwIlNbBHioedAWolzTVl6tmMaXP1RmCMyYv+U+ukvo9gwA10mLW0eFbyW4n/oC4UIN12gTMn/w==",
"dev": true
},
"node_modules/emoji-regex": {
@ -2583,9 +2609,9 @@
}
},
"node_modules/javascript-stringify": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/javascript-stringify/-/javascript-stringify-2.0.1.tgz",
"integrity": "sha512-yV+gqbd5vaOYjqlbk16EG89xB5udgjqQF3C5FAORDg4f/IS1Yc5ERCv5e/57yBcfJYw05V5JyIXabhwb75Xxow==",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/javascript-stringify/-/javascript-stringify-2.1.0.tgz",
"integrity": "sha512-JVAfqNPTvNq3sB/VHQJAFxN/sPgKnsKrCwyRt15zwNCdrMMJDdcEOdubuy+DuJYYdm0ox1J4uzEuYKkN+9yhVg==",
"dev": true
},
"node_modules/jest-worker": {
@ -4228,6 +4254,19 @@
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.3.tgz",
"integrity": "sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ=="
},
"node_modules/typescript": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz",
"integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
},
"node_modules/uniq": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz",
@ -4264,6 +4303,12 @@
"integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==",
"dev": true
},
"node_modules/vue": {
"version": "2.6.12",
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.12.tgz",
"integrity": "sha512-uhmLFETqPPNyuLLbsKz6ioJ4q7AZHzD8ZVFNATNyICSZouqP2Sz0rotWQC8UNBF6VGSCs5abnKJoStA6JbCbfg==",
"dev": true
},
"node_modules/vue-hot-reload-api": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz",
@ -5111,6 +5156,28 @@
"sprintf-js": "^1.1.1"
}
},
"@nativescript/types": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/@nativescript/types/-/types-8.0.0.tgz",
"integrity": "sha512-xfVLHZ4L0T7/Y4v+BBmH+GBvYRqYtasi8YaG4QV5oZPLKu2sBGjQkhME3ghx/FTh+0QRwMbSU8FJKkyK35rR3A==",
"dev": true,
"requires": {
"@nativescript/types-android": "8.0.0",
"@nativescript/types-ios": "8.0.0"
}
},
"@nativescript/types-android": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/@nativescript/types-android/-/types-android-8.0.0.tgz",
"integrity": "sha512-4b/RHhXjX/KLLNLiuCCOWNFnXhK5/3+mGkO/eXJbY1DbCDol4Fv8hbpRHridrhwihZAvqE0rVi5RlLFCtS2TBg==",
"dev": true
},
"@nativescript/types-ios": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/@nativescript/types-ios/-/types-ios-8.0.0.tgz",
"integrity": "sha512-QarxaXGN+T+33kDC+FtIY1b3xgHHfJODtXqbTQJxxV4HPiCx8dEDTT746xkQtH8j1F/92Q3oY4h0B5HhJS0QvQ==",
"dev": true
},
"@nativescript/webpack": {
"version": "5.0.0-beta.6",
"resolved": "https://registry.npmjs.org/@nativescript/webpack/-/webpack-5.0.0-beta.6.tgz",
@ -6174,9 +6241,9 @@
"dev": true
},
"electron-to-chromium": {
"version": "1.3.713",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.713.tgz",
"integrity": "sha512-HWgkyX4xTHmxcWWlvv7a87RHSINEcpKYZmDMxkUlHcY+CJcfx7xEfBHuXVsO1rzyYs1WQJ7EgDp2CoErakBIow==",
"version": "1.3.716",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.716.tgz",
"integrity": "sha512-yUWKAfpJH5ovgwIlNbBHioedAWolzTVl6tmMaXP1RmCMyYv+U+ukvo9gwA10mLW0eFbyW4n/oC4UIN12gTMn/w==",
"dev": true
},
"emoji-regex": {
@ -6751,9 +6818,9 @@
"dev": true
},
"javascript-stringify": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/javascript-stringify/-/javascript-stringify-2.0.1.tgz",
"integrity": "sha512-yV+gqbd5vaOYjqlbk16EG89xB5udgjqQF3C5FAORDg4f/IS1Yc5ERCv5e/57yBcfJYw05V5JyIXabhwb75Xxow==",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/javascript-stringify/-/javascript-stringify-2.1.0.tgz",
"integrity": "sha512-JVAfqNPTvNq3sB/VHQJAFxN/sPgKnsKrCwyRt15zwNCdrMMJDdcEOdubuy+DuJYYdm0ox1J4uzEuYKkN+9yhVg==",
"dev": true
},
"jest-worker": {
@ -7963,6 +8030,12 @@
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.3.tgz",
"integrity": "sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ=="
},
"typescript": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz",
"integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==",
"dev": true
},
"uniq": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz",
@ -7996,6 +8069,12 @@
"integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==",
"dev": true
},
"vue": {
"version": "2.6.12",
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.12.tgz",
"integrity": "sha512-uhmLFETqPPNyuLLbsKz6ioJ4q7AZHzD8ZVFNATNyICSZouqP2Sz0rotWQC8UNBF6VGSCs5abnKJoStA6JbCbfg==",
"dev": true
},
"vue-hot-reload-api": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz",

View file

@ -1,6 +1,6 @@
{
"name": "enrecipes",
"main": "./app/main.js",
"main": "./app/main.ts",
"version": "1.0.0",
"description": "A native application built with NativeScript-Vue",
"homepage": "https://enrecipes.vercel.app/",
@ -31,8 +31,12 @@
},
"devDependencies": {
"@nativescript/android": "8.0.0",
"@nativescript/types": "^8.0.0",
"@nativescript/webpack": "beta",
"@types/node": "^14.14.37",
"nativescript-vue-template-compiler": "~2.9.0",
"sass": "^1.32.8"
"sass": "^1.32.8",
"typescript": "^4.2.4",
"vue": "^2.6.12"
}
}

25
tsconfig.json Normal file
View file

@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "es2017",
"module": "esnext",
"moduleResolution": "node",
"lib": ["dom", "es2017"],
"sourceMap": true,
"noEmitHelpers": true,
"importHelpers": true,
"baseUrl": ".",
"paths": {
"~/*": ["app/*"],
"@/*": ["app/*"]
},
"typeRoots": ["types"],
"types": ["node"],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"skipLibCheck": true
},
"include": ["app", "types"],
"exclude": ["node_modules", "platforms"]
}

1
types/references.d.ts vendored Normal file
View file

@ -0,0 +1 @@
/// <reference path="../node_modules/@nativescript/types/index.d.ts" />

4
types/shims.vue.d.ts vendored Normal file
View file

@ -0,0 +1,4 @@
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}

View file

@ -1,357 +1,6 @@
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!');
}
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;
};
webpack.init(env)
return webpack.resolveConfig()
}