mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore(e2e): clean up webpack files (#5807)
This commit is contained in:
committed by
Stanimira Vlaeva
parent
1e682bf707
commit
0ddd9281e6
76
.gitignore
vendored
76
.gitignore
vendored
@@ -1,4 +1,41 @@
|
|||||||
# generated files
|
# Folders
|
||||||
|
dist
|
||||||
|
hooks
|
||||||
|
libs
|
||||||
|
node_modules
|
||||||
|
package
|
||||||
|
platforms
|
||||||
|
reports
|
||||||
|
tags
|
||||||
|
|
||||||
|
# Files
|
||||||
|
package-lock.json
|
||||||
|
.DS_Store
|
||||||
|
.nsbuildinfo
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
/.idea
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
|
||||||
|
# IDE - VSCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
|
||||||
|
# Appium files
|
||||||
|
e2e/**/*.trace/
|
||||||
|
e2e/**/test-results.xml
|
||||||
|
|
||||||
|
# Webpack configuration files
|
||||||
|
webpack.config.js
|
||||||
|
|
||||||
|
# Generated files
|
||||||
*.map
|
*.map
|
||||||
*.tgz
|
*.tgz
|
||||||
.baseDir.ts
|
.baseDir.ts
|
||||||
@@ -6,10 +43,7 @@
|
|||||||
tscommand*.tmp.txt
|
tscommand*.tmp.txt
|
||||||
.tscache
|
.tscache
|
||||||
|
|
||||||
node_modules/
|
# Other
|
||||||
dist/
|
|
||||||
package/
|
|
||||||
|
|
||||||
*.js
|
*.js
|
||||||
!tests/hooks/**/*.*
|
!tests/hooks/**/*.*
|
||||||
!gruntfile.js
|
!gruntfile.js
|
||||||
@@ -19,44 +53,14 @@ package/
|
|||||||
!fetch/**/*.*
|
!fetch/**/*.*
|
||||||
!apps/TelerikNEXT/lib/**/*.*
|
!apps/TelerikNEXT/lib/**/*.*
|
||||||
!build/**/*.*
|
!build/**/*.*
|
||||||
CrossPlatformModules.sln.ide/
|
|
||||||
*.suo
|
|
||||||
CrossPlatformModules.suo
|
|
||||||
CrossPlatformModules.v14.suo
|
|
||||||
CrossPlatformModules.csproj.user
|
|
||||||
bin/
|
|
||||||
obj/
|
|
||||||
.vs/
|
.vs/
|
||||||
.idea/
|
|
||||||
|
|
||||||
.baseDir.ts
|
.baseDir.ts
|
||||||
.ctags-exclude
|
.ctags-exclude
|
||||||
tags
|
|
||||||
|
|
||||||
TestRunResult.txt
|
TestRunResult.txt
|
||||||
.testsapprun
|
.testsapprun
|
||||||
|
|
||||||
tns-core-modules.base.d.ts
|
tns-core-modules.base.d.ts
|
||||||
tns-core-modules.d.ts
|
tns-core-modules.d.ts
|
||||||
tns-core-modules.es6.d.ts
|
tns-core-modules.es6.d.ts
|
||||||
|
|
||||||
tests/platforms/
|
|
||||||
tests/lib/
|
|
||||||
*.log
|
|
||||||
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
apps/platforms/
|
|
||||||
apps/lib/
|
|
||||||
apps/hooks/
|
|
||||||
apps/node_modules/
|
|
||||||
|
|
||||||
e2e/**/platforms
|
|
||||||
!e2e/**/webpack.config.js
|
|
||||||
e2e/**/reports/
|
|
||||||
e2e/**/*.trace/
|
|
||||||
e2e/**/test-results.xml
|
|
||||||
|
|
||||||
package-lock.json
|
|
||||||
|
|
||||||
.nsbuildinfo
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
require("application");
|
|
||||||
if (!global["__snapshot"]) {
|
|
||||||
// In case snapshot generation is enabled these modules will get into the bundle
|
|
||||||
// but will not be required/evaluated.
|
|
||||||
// The snapshot webpack plugin will add them to the tns-java-classes.js bundle file.
|
|
||||||
// This way, they will be evaluated on app start as early as possible.
|
|
||||||
require("ui/frame");
|
|
||||||
require("ui/frame/activity");
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
// There is a bug in angular: https://github.com/angular/angular-cli/pull/8589/files
|
|
||||||
// Legendary stuff, its webpack plugin pretty much doesn't work with empty TypeScript files in v1.8.3
|
|
||||||
// tslint:disable-next-line:no-unused-expression
|
|
||||||
void 0;
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
// Snapshot the ~/app.css and the theme
|
|
||||||
const application = require("application");
|
|
||||||
require("ui/styling/style-scope");
|
|
||||||
const appCssContext = require.context("~/", false, /^\.\/app\.(css|scss|less|sass)$/);
|
|
||||||
global.registerWebpackModules(appCssContext);
|
|
||||||
application.loadAppCss();
|
|
||||||
|
|
||||||
require("./vendor-platform");
|
|
||||||
|
|
||||||
require("bundle-entry-points");
|
|
||||||
@@ -17,28 +17,9 @@
|
|||||||
"tns-core-modules": "next"
|
"tns-core-modules": "next"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"awesome-typescript-loader": "~3.1.3",
|
|
||||||
"babel-traverse": "6.26.0",
|
|
||||||
"babel-types": "6.26.0",
|
|
||||||
"babylon": "6.18.0",
|
|
||||||
"copy-webpack-plugin": "~4.3.0",
|
|
||||||
"css-loader": "~0.28.7",
|
|
||||||
"extract-text-webpack-plugin": "~3.0.2",
|
|
||||||
"lazy": "1.0.11",
|
|
||||||
"nativescript-dev-appium": "next",
|
"nativescript-dev-appium": "next",
|
||||||
"nativescript-dev-typescript": "next",
|
"nativescript-dev-typescript": "next",
|
||||||
"nativescript-dev-webpack": "next",
|
"nativescript-dev-webpack": "next"
|
||||||
"nativescript-worker-loader": "~0.8.1",
|
|
||||||
"raw-loader": "~0.5.1",
|
|
||||||
"resolve-url-loader": "~2.2.1",
|
|
||||||
"typescript": "~2.4.2",
|
|
||||||
"uglifyjs-webpack-plugin": "~1.1.6",
|
|
||||||
"webpack": "~3.10.0",
|
|
||||||
"webpack-bundle-analyzer": "^2.9.1",
|
|
||||||
"webpack-sources": "~1.1.0",
|
|
||||||
"@types/chai": "^4.0.2",
|
|
||||||
"@types/mocha": "^2.2.41",
|
|
||||||
"@types/node": "^7.0.5"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"e2e": "tsc -p e2e && mocha --opts ./e2e/config/mocha.opts",
|
"e2e": "tsc -p e2e && mocha --opts ./e2e/config/mocha.opts",
|
||||||
|
|||||||
@@ -1,143 +0,0 @@
|
|||||||
const { resolve, join } = require("path");
|
|
||||||
|
|
||||||
const webpack = require("webpack");
|
|
||||||
const nsWebpack = require("nativescript-dev-webpack");
|
|
||||||
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
|
|
||||||
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
||||||
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
|
|
||||||
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
|
|
||||||
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
|
|
||||||
|
|
||||||
module.exports = env => {
|
|
||||||
const platform = env && (env.android && "android" || env.ios && "ios");
|
|
||||||
if (!platform) {
|
|
||||||
throw new Error("You need to provide a target platform!");
|
|
||||||
}
|
|
||||||
const platforms = ["ios", "android"];
|
|
||||||
const { snapshot, uglify, report } = env;
|
|
||||||
|
|
||||||
const config = {
|
|
||||||
context: resolve("./app"),
|
|
||||||
target: nativescriptTarget,
|
|
||||||
entry: {
|
|
||||||
bundle: `./${nsWebpack.getEntryModule()}`,
|
|
||||||
vendor: "./vendor"
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
pathinfo: true,
|
|
||||||
// Default destination inside platforms/<platform>/...
|
|
||||||
path: resolve(nsWebpack.getAppPath(platform)),
|
|
||||||
libraryTarget: "commonjs2",
|
|
||||||
filename: "[name].js",
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
extensions: [".ts", ".js", ".scss", ".css"],
|
|
||||||
// Resolve {N} system modules from tns-core-modules
|
|
||||||
modules: [
|
|
||||||
"node_modules/tns-core-modules",
|
|
||||||
"node_modules",
|
|
||||||
],
|
|
||||||
alias: {
|
|
||||||
'~': resolve("./app")
|
|
||||||
},
|
|
||||||
// don't resolve symlinks to symlinked modules
|
|
||||||
symlinks: false
|
|
||||||
},
|
|
||||||
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",
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{ test: /\.(html|xml)$/, use: "raw-loader" },
|
|
||||||
|
|
||||||
{
|
|
||||||
test: /\.css$/,
|
|
||||||
use: { loader: "css-loader", options: { minimize: false, url: false } }
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
test: /\.scss$/,
|
|
||||||
use: [
|
|
||||||
{ loader: "css-loader", options: { minimize: false, url: false } },
|
|
||||||
"sass-loader"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{ test: /\.ts$/, use: "awesome-typescript-loader" }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
// Vendor libs go to the vendor.js chunk
|
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
|
||||||
name: ["vendor"],
|
|
||||||
}),
|
|
||||||
// Define useful constants like TNS_WEBPACK
|
|
||||||
new webpack.DefinePlugin({
|
|
||||||
"global.TNS_WEBPACK": "true",
|
|
||||||
}),
|
|
||||||
// Copy assets to out dir. Add your own globs as needed.
|
|
||||||
new CopyWebpackPlugin([
|
|
||||||
{ from: "App_Resources/**" },
|
|
||||||
{ from: "fonts/**" },
|
|
||||||
{ from: "**/*.jpg" },
|
|
||||||
{ from: "**/*.png" },
|
|
||||||
{ from: "**/*.xml" },
|
|
||||||
]),
|
|
||||||
// Generate a bundle starter script and activate it in package.json
|
|
||||||
new nsWebpack.GenerateBundleStarterPlugin([
|
|
||||||
"./vendor",
|
|
||||||
"./bundle",
|
|
||||||
]),
|
|
||||||
// Support for web workers since v3.2
|
|
||||||
new NativeScriptWorkerPlugin(),
|
|
||||||
new nsWebpack.PlatformFSPlugin({
|
|
||||||
platform,
|
|
||||||
platforms,
|
|
||||||
// ignore: ["App_Resources"]
|
|
||||||
}),
|
|
||||||
// Does IPC communication with the {N} CLI to notify events when running in watch mode.
|
|
||||||
new nsWebpack.WatchStateLoggerPlugin(),
|
|
||||||
],
|
|
||||||
};
|
|
||||||
if (report) {
|
|
||||||
// Generate report files for bundles content
|
|
||||||
config.plugins.push(new BundleAnalyzerPlugin({
|
|
||||||
analyzerMode: "static",
|
|
||||||
openAnalyzer: false,
|
|
||||||
generateStatsFile: true,
|
|
||||||
reportFilename: join(__dirname, "report", `report.html`),
|
|
||||||
statsFilename: join(__dirname, "report", `stats.json`),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
if (snapshot) {
|
|
||||||
config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({
|
|
||||||
chunk: "vendor",
|
|
||||||
projectRoot: __dirname,
|
|
||||||
webpackConfig: config,
|
|
||||||
targetArchs: ["arm", "arm64", "ia32"],
|
|
||||||
tnsJavaClassesOptions: { packages: ["tns-core-modules" ] },
|
|
||||||
useLibs: false
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
if (uglify) {
|
|
||||||
config.plugins.push(new webpack.LoaderOptionsPlugin({ minimize: true }));
|
|
||||||
|
|
||||||
// Work around an Android issue by setting compress = false
|
|
||||||
const compress = platform !== "android";
|
|
||||||
config.plugins.push(new UglifyJsPlugin({
|
|
||||||
uglifyOptions: {
|
|
||||||
mangle: { reserved: nsWebpack.uglifyMangleExcludes },
|
|
||||||
compress,
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
return config;
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user