Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

fix(prepare): clean platforms/.../app/ when running webpack #465

Merged
merged 1 commit into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dependencyManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function getRequiredDeps(packageJson) {
"webpack": "~3.10.0",
"webpack-bundle-analyzer": "^2.9.1",
"webpack-sources": "~1.1.0",
"clean-webpack-plugin": "~0.1.19",
"copy-webpack-plugin": "~4.3.0",
"raw-loader": "~0.5.1",
"css-loader": "~0.28.7",
Expand Down
12 changes: 9 additions & 3 deletions templates/webpack.angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { resolve, join } = require("path");
const webpack = require("webpack");
const nsWebpack = require("nativescript-dev-webpack");
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
Expand All @@ -13,6 +14,11 @@ module.exports = env => {
if (!platform) {
throw new Error("You need to provide a target platform!");
}

const projectRoot = __dirname;
// Default destination inside platforms/<platform>/...
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform));

const platforms = ["ios", "android"];
const {
// The 'appPath' and 'appResourcesDir' values are fetched from
Expand All @@ -31,7 +37,6 @@ module.exports = env => {
} = env;
const ngToolsWebpackOptions = { tsConfigPath: join(__dirname, "tsconfig.json") };

const projectRoot = __dirname;
const appFullPath = resolve(projectRoot, appPath);
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);

Expand All @@ -53,8 +58,7 @@ module.exports = env => {
},
output: {
pathinfo: true,
// Default destination inside platforms/<platform>/...
path: resolve(nsWebpack.getAppPath(platform)),
path: dist,
libraryTarget: "commonjs2",
filename: "[name].js",
},
Expand Down Expand Up @@ -122,6 +126,8 @@ module.exports = env => {
new webpack.DefinePlugin({
"global.TNS_WEBPACK": "true",
}),
// Remove all files from the out dir.
new CleanWebpackPlugin([ `${dist}/**/*` ]),
// Copy assets to out dir. Add your own globs as needed.
new CopyWebpackPlugin([
{ from: `${appResourcesFullPath}/**`, context: projectRoot },
Expand Down
12 changes: 9 additions & 3 deletions templates/webpack.javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { resolve, join } = require("path");
const webpack = require("webpack");
const nsWebpack = require("nativescript-dev-webpack");
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
Expand All @@ -13,6 +14,11 @@ module.exports = env => {
if (!platform) {
throw new Error("You need to provide a target platform!");
}

const projectRoot = __dirname;
// Default destination inside platforms/<platform>/...
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform));

const platforms = ["ios", "android"];
const {
// The 'appPath' and 'appResourcesPath' values are fetched from
Expand All @@ -29,7 +35,6 @@ module.exports = env => {
report,
} = env;

const projectRoot = __dirname;
const appFullPath = resolve(projectRoot, appPath);
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);

Expand All @@ -49,8 +54,7 @@ module.exports = env => {
},
output: {
pathinfo: true,
// Default destination inside platforms/<platform>/...
path: resolve(nsWebpack.getAppPath(platform)),
path: dist,
libraryTarget: "commonjs2",
filename: "[name].js",
},
Expand Down Expand Up @@ -105,6 +109,8 @@ module.exports = env => {
new webpack.DefinePlugin({
"global.TNS_WEBPACK": "true",
}),
// Remove all files from the out dir.
new CleanWebpackPlugin([ `${dist}/**/*` ]),
// Copy assets to out dir. Add your own globs as needed.
new CopyWebpackPlugin([
{ from: `${appResourcesFullPath}/**`, context: projectRoot },
Expand Down
12 changes: 9 additions & 3 deletions templates/webpack.typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { resolve, join } = require("path");
const webpack = require("webpack");
const nsWebpack = require("nativescript-dev-webpack");
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
Expand All @@ -13,6 +14,11 @@ module.exports = env => {
if (!platform) {
throw new Error("You need to provide a target platform!");
}

const projectRoot = __dirname;
// Default destination inside platforms/<platform>/...
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform));

const platforms = ["ios", "android"];
const {
// The 'appPath' and 'appResourcesDir' values are fetched from
Expand All @@ -29,7 +35,6 @@ module.exports = env => {
report,
} = env;

const projectRoot = __dirname;
const appFullPath = resolve(projectRoot, appPath);
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);

Expand All @@ -49,8 +54,7 @@ module.exports = env => {
},
output: {
pathinfo: true,
// Default destination inside platforms/<platform>/...
path: resolve(nsWebpack.getAppPath(platform)),
path: dist,
libraryTarget: "commonjs2",
filename: "[name].js",
},
Expand Down Expand Up @@ -107,6 +111,8 @@ module.exports = env => {
new webpack.DefinePlugin({
"global.TNS_WEBPACK": "true",
}),
// Remove all files from the out dir.
new CleanWebpackPlugin([ `${dist}/**/*` ]),
// Copy assets to out dir. Add your own globs as needed.
new CopyWebpackPlugin([
{ from: `${appResourcesFullPath}/**`, context: projectRoot },
Expand Down