Commit c64ff23a authored by dev0tion's avatar dev0tion

Update to Angular 5

parent ec5ad760
...@@ -41,44 +41,47 @@ ...@@ -41,44 +41,47 @@
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
"@angular/animations": "4.4.5", "@angular/animations": "5.0.2",
"@angular/common": "4.4.5", "@angular/common": "5.0.2",
"@angular/compiler": "4.4.5", "@angular/compiler": "5.0.2",
"@angular/core": "4.4.5", "@angular/core": "5.0.2",
"@angular/forms": "4.4.5", "@angular/forms": "5.0.2",
"@angular/http": "4.4.5", "@angular/http": "5.0.2",
"@angular/platform-browser": "4.4.5", "@angular/platform-browser": "5.0.2",
"@angular/platform-browser-dynamic": "4.4.5", "@angular/platform-browser-dynamic": "5.0.2",
"@angular/platform-server": "4.4.5", "@angular/platform-server": "5.0.2",
"@angular/router": "4.4.5", "@angular/router": "5.0.2",
"@ng-bootstrap/ng-bootstrap": "1.0.0-beta.5", "@ng-bootstrap/ng-bootstrap": "1.0.0-beta.5",
"bootstrap": "4.0.0-beta", "bootstrap": "4.0.0-beta",
"core-js": "2.5.1", "core-js": "2.5.1",
"electron-context-menu": "0.9.1", "electron-context-menu": "0.9.1",
"enhanced-resolve": "3.4.1", "enhanced-resolve": "3.4.1",
"ngx-clipboard": "8.1.1", "ngx-clipboard": "8.1.1",
"ngx-bootstrap": "1.9.3", "ngx-bootstrap": "2.0.0-beta.8",
"rxjs": "5.4.3", "rxjs": "5.5.2",
"zone.js": "0.8.18" "zone.js": "0.8.18"
}, },
"devDependencies": { "devDependencies": {
"@angular/cli": "1.4.7", "@angular/cli": "1.5.3",
"@angular/compiler-cli": "4.4.5", "@angular/compiler-cli": "5.0.2",
"@types/core-js": "0.9.36", "@types/core-js": "0.9.36",
"@types/jasmine": "2.6.0", "@types/jasmine": "2.6.0",
"@types/node": "7.0.7", "@types/node": "7.0.7",
"autoprefixer": "7.1.5", "autoprefixer": "7.1.6",
"codelyzer": "3.2.1", "circular-dependency-plugin": "4.2.1",
"codelyzer": "4.0.1",
"copyfiles": "1.2.0", "copyfiles": "1.2.0",
"cross-env": "5.1.0", "copy-webpack-plugin": "4.2.1",
"cross-env": "5.1.1",
"css-loader": "0.28.7", "css-loader": "0.28.7",
"cssnano": "3.10.0", "cssnano": "3.10.0",
"electron": "1.7.9", "electron": "1.7.9",
"electron-packager": "9.1.0", "electron-packager": "10.1.0",
"electron-reload": "1.2.2", "electron-reload": "1.2.2",
"exports-loader": "0.6.4", "exports-loader": "0.6.4",
"file-loader": "1.1.5", "file-loader": "1.1.5",
"html-loader": "0.5.1", "html-loader": "0.5.1",
"html-webpack-plugin": "2.30.1",
"istanbul-instrumenter-loader": "3.0.0", "istanbul-instrumenter-loader": "3.0.0",
"jasmine-core": "2.8.0", "jasmine-core": "2.8.0",
"jasmine-spec-reporter": "4.2.1", "jasmine-spec-reporter": "4.2.1",
...@@ -94,23 +97,25 @@ ...@@ -94,23 +97,25 @@
"less-loader": "4.0.5", "less-loader": "4.0.5",
"minimist": "1.2.0", "minimist": "1.2.0",
"mkdirp": "0.5.1", "mkdirp": "0.5.1",
"npm-run-all": "4.1.1", "npm-run-all": "4.1.2",
"node-sass": "4.5.3", "node-sass": "4.7.2",
"postcss-loader": "2.0.8", "postcss-loader": "2.0.8",
"postcss-url": "7.1.2", "postcss-url": "7.2.1",
"protractor": "5.2.0", "protractor": "5.2.0",
"raw-loader": "0.5.1", "raw-loader": "0.5.1",
"sass-loader": "6.0.6", "sass-loader": "6.0.6",
"script-loader": "0.7.2", "script-loader": "0.7.2",
"source-map-loader": "0.2.2", "source-map-loader": "0.2.3",
"style-loader": "0.19.0", "style-loader": "0.19.0",
"stylus-loader": "3.0.1", "stylus-loader": "3.0.1",
"ts-node": "3.3.0", "ts-node": "3.3.0",
"tslint": "5.7.0", "tslint": "5.8.0",
"typescript": "2.5.3", "typescript": "2.6.1",
"uglifyjs-webpack-plugin": "1.1.0",
"url-loader": "0.6.2", "url-loader": "0.6.2",
"webdriver-manager": "12.0.6", "webdriver-manager": "12.0.6",
"webpack": "3.8.1", "webpack": "3.8.1",
"webpack-dev-server": "2.9.2" "webpack-concat-plugin": "1.4.2",
"webpack-dev-server": "2.9.4"
} }
} }
export const environment = { export const environment = {
production: true production: true,
silent: false
}; };
...@@ -4,5 +4,6 @@ ...@@ -4,5 +4,6 @@
// The list of which env maps to which file can be found in `angular-cli.json`. // The list of which env maps to which file can be found in `angular-cli.json`.
export const environment = { export const environment = {
production: false production: false,
silent: false
}; };
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
"es2016", "es2016",
"dom" "dom"
] ]
} },
,
"exclude": [ "exclude": [
"node_modules" "node_modules"
] ]
......
const fs = require('fs');
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const CopyWebpackPlugin = require('copy-webpack-plugin');
const ProgressPlugin = require('webpack/lib/ProgressPlugin'); const ProgressPlugin = require('webpack/lib/ProgressPlugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin'); const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const autoprefixer = require('autoprefixer'); const autoprefixer = require('autoprefixer');
const postcssUrl = require('postcss-url'); const postcssUrl = require('postcss-url');
const ConcatPlugin = require('webpack-concat-plugin'); const customProperties = require('postcss-custom-properties');
const { NoEmitOnErrorsPlugin, LoaderOptionsPlugin, DefinePlugin, HashedModuleIdsPlugin } = require('webpack'); const { NoEmitOnErrorsPlugin, SourceMapDevToolPlugin, DefinePlugin, NamedModulesPlugin } = require('webpack');
const { GlobCopyWebpackPlugin, BaseHrefWebpackPlugin, InsertConcatAssetsWebpackPlugin } = require('@angular/cli/plugins/webpack'); const { BaseHrefWebpackPlugin, NamedLazyChunksWebpackPlugin, InsertConcatAssetsWebpackPlugin } = require('@angular/cli/plugins/webpack');
const { CommonsChunkPlugin, UglifyJsPlugin } = require('webpack').optimize; const { CommonsChunkPlugin } = require('webpack').optimize;
const { AotPlugin } = require('@ngtools/webpack'); const { AngularCompilerPlugin } = require('@ngtools/webpack');
const ConcatPlugin = require('webpack-concat-plugin');
const nodeModules = path.join(process.cwd(), 'node_modules'); const nodeModules = path.join(process.cwd(), 'node_modules');
const realNodeModules = fs.realpathSync(nodeModules);
const genDirNodeModules = path.join(process.cwd(), 'src', '$$_gendir', 'node_modules');
const entryPoints = ["inline", "polyfills", "sw-register", "styles", "vendor", "main"]; const entryPoints = ["inline", "polyfills", "sw-register", "styles", "vendor", "main"];
const minimizeCss = false;
const baseHref = ""; const baseHref = "";
const deployUrl = ""; const deployUrl = "";
const postcssPlugins = function () {
const importantCommentRe = /@preserve|@license|[@#]\s*source(?:Mapping)?URL|^!/i;
const minimizeOptions = {
autoprefixer: false,
safe: true,
mergeLonghand: false,
discardComments: { remove: (comment) => !importantCommentRe.test(comment) }
};
return [
postcssUrl({
url: (obj) => {
if (!obj.url.startsWith('/') || obj.url.startsWith('//')) {
return obj.url;
}
if (deployUrl.match(/:\/\//)) {
// If deployUrl contains a scheme, ignore baseHref use deployUrl as is.
return `${deployUrl.replace(/\/$/, '')}${obj.url}`;
}
else if (baseHref.match(/:\/\//)) {
// If baseHref contains a scheme, include it as is.
return baseHref.replace(/\/$/, '') +
`/${deployUrl}/${obj.url}`.replace(/\/\/+/g, '/');
}
else {
// Join together base-href, deploy-url and the original URL.
// Also dedupe multiple slashes into single ones.
return `/${baseHref}/${deployUrl}/${obj.url}`.replace(/\/\/+/g, '/');
}
}
}),
autoprefixer(),
customProperties({ preserve: true })
].concat(minimizeCss ? [cssnano(minimizeOptions)] : []);
};
const isProd = (process.env.NODE_ENV === 'production'); const isProd = (process.env.NODE_ENV === 'production');
//add all external css to be added in our index.html--> like as if it's .angular-cli.json //add all external css to be added in our index.html--> like as if it's .angular-cli.json
...@@ -44,7 +85,7 @@ function getPlugins() { ...@@ -44,7 +85,7 @@ function getPlugins() {
plugins.push(new NoEmitOnErrorsPlugin()); plugins.push(new NoEmitOnErrorsPlugin());
if(scripts.length > 0){ if (scripts.length > 0) {
plugins.push(new ConcatPlugin({ plugins.push(new ConcatPlugin({
"uglify": false, "uglify": false,
"sourceMap": true, "sourceMap": true,
...@@ -57,20 +98,39 @@ function getPlugins() { ...@@ -57,20 +98,39 @@ function getPlugins() {
])); ]));
} }
plugins.push(new GlobCopyWebpackPlugin({ plugins.push(new CopyWebpackPlugin([
"patterns": [ {
"assets", "context": "src",
"favicon.ico" "to": "",
], "from": {
"globOptions": { "glob": "assets/**/*",
"cwd": process.cwd() + "/src", "dot": true
"dot": true,
"ignore": "**/.gitkeep"
} }
},
{
"context": "src",
"to": "",
"from": {
"glob": "favicon.ico",
"dot": true
}
}
], {
"ignore": [
".gitkeep"
],
"debug": "warning"
})); }));
plugins.push(new ProgressPlugin()); plugins.push(new ProgressPlugin());
plugins.push(new CircularDependencyPlugin({
"exclude": /(\\|\/)node_modules(\\|\/)/,
"failOnError": false
}));
plugins.push(new NamedLazyChunksWebpackPlugin());
plugins.push(new HtmlWebpackPlugin({ plugins.push(new HtmlWebpackPlugin({
"template": "./src/index.html", "template": "./src/index.html",
"filename": "./index.html", "filename": "./index.html",
...@@ -103,98 +163,74 @@ function getPlugins() { ...@@ -103,98 +163,74 @@ function getPlugins() {
plugins.push(new BaseHrefWebpackPlugin({})); plugins.push(new BaseHrefWebpackPlugin({}));
plugins.push(new CommonsChunkPlugin({ plugins.push(new CommonsChunkPlugin({
"name": "inline", "name": [
"inline"
],
"minChunks": null "minChunks": null
})); }));
plugins.push(new CommonsChunkPlugin({ plugins.push(new CommonsChunkPlugin({
"name": "vendor", "name": [
"minChunks": (module) => module.resource && module.resource.startsWith(nodeModules), "vendor"
],
"minChunks": (module) => {
return module.resource
&& (module.resource.startsWith(nodeModules)
|| module.resource.startsWith(genDirNodeModules)
|| module.resource.startsWith(realNodeModules));
},
"chunks": [ "chunks": [
"main" "main"
] ]
})); }));
plugins.push(new ExtractTextPlugin({ plugins.push(new SourceMapDevToolPlugin({
"filename": "[name].bundle.css", "filename": "[file].map[query]",
"disable": true "moduleFilenameTemplate": "[resource-path]",
"fallbackModuleFilenameTemplate": "[resource-path]?[hash]",
"sourceRoot": "webpack:///"
})); }));
plugins.push(new LoaderOptionsPlugin({ plugins.push(new CommonsChunkPlugin({
"sourceMap": false, "name": [
"options": { "main"
"postcss": [
autoprefixer(),
postcssUrl({
"url": (obj) => {
// Only convert root relative URLs, which CSS-Loader won't process into require().
if (!obj.url.startsWith('/') || obj.url.startsWith('//')) {
return obj.url;
}
if (deployUrl.match(/:\/\//)) {
// If deployUrl contains a scheme, ignore baseHref use deployUrl as is.
return `${deployUrl.replace(/\/$/, '')}${obj.url}`;
}
else if (baseHref.match(/:\/\//)) {
// If baseHref contains a scheme, include it as is.
return baseHref.replace(/\/$/, '') +
`/${deployUrl}/${obj.url}`.replace(/\/\/+/g, '/');
}
else {
// Join together base-href, deploy-url and the original URL.
// Also dedupe multiple slashes into single ones.
return `/${baseHref}/${deployUrl}/${obj.url}`.replace(/\/\/+/g, '/');
}
}
})
], ],
"sassLoader": { "minChunks": 2,
"sourceMap": false, "async": "common"
"includePaths": []
},
"lessLoader": {
"sourceMap": false
},
"context": ""
}
})); }));
if (isProd) { plugins.push(new NamedModulesPlugin({}));
plugins.push(new HashedModuleIdsPlugin({
"hashFunction": "md5",
"hashDigest": "base64",
"hashDigestLength": 4
}));
plugins.push(new AotPlugin({ if (isProd) {
plugins.push(new AngularCompilerPlugin({
"mainPath": "main.ts", "mainPath": "main.ts",
"platform": 0,
"sourceMap": true,
"tsConfigPath": "src/tsconfig.app.json",
"skipCodeGeneration": true,
"compilerOptions": {},
"hostReplacementPaths": { "hostReplacementPaths": {
"environments/index.ts": "environments/environment.prod.ts" "environments/index.ts": "environments/index.prod.ts"
}, },
"exclude": [], "exclude": []
"tsConfigPath": "src/tsconfig.app.json"
})); }));
plugins.push(new UglifyJsPlugin({ plugins.push(new UglifyJsPlugin({
"mangle": {
"screw_ie8": true
},
"compress": {
"screw_ie8": true,
"warnings": false
},
"sourceMap": false "sourceMap": false
})); }));
} else { } else {
plugins.push(new AotPlugin({ plugins.push(new AngularCompilerPlugin({
"mainPath": "main.ts", "mainPath": "main.ts",
"platform": 0,
"sourceMap": true,
"tsConfigPath": "src/tsconfig.app.json",
"skipCodeGeneration": true,
"compilerOptions": {},
"hostReplacementPaths": { "hostReplacementPaths": {
"environments/index.ts": "environments/environment.ts" "environments/index.ts": "environments/index.ts"
}, },
"exclude": [], "exclude": []
"tsConfigPath": "src/tsconfig.app.json",
"skipCodeGeneration": true
})); }));
} }
...@@ -205,6 +241,7 @@ module.exports = { ...@@ -205,6 +241,7 @@ module.exports = {
"devtool": "source-map", "devtool": "source-map",
"externals": { "externals": {
"electron": "require('electron')", "electron": "require('electron')",
"buffer": "require('buffer')",
"child_process": "require('child_process')", "child_process": "require('child_process')",
"crypto": "require('crypto')", "crypto": "require('crypto')",
"events": "require('events')", "events": "require('events')",
...@@ -230,14 +267,20 @@ module.exports = { ...@@ -230,14 +267,20 @@ module.exports = {
".ts", ".ts",
".js", ".js",
".scss", ".scss",
".css",
".json" ".json"
], ],
"aliasFields": [], "aliasFields": [],
"alias": { // WORKAROUND See. angular-cli/issues/5433 "alias": { // WORKAROUND See. angular-cli/issues/5433
"environments": isProd ? path.resolve(__dirname, 'src/environments/environment.prod.ts') : path.resolve(__dirname, 'src/environments/environment.ts') "environments": isProd ? path.resolve(__dirname, 'src/environments/index.prod.ts') : path.resolve(__dirname, 'src/environments/index.ts')
}, },
"modules": [ "modules": [
"./node_modules" "./node_modules"
],
"mainFields": [
"browser",
"module",
"main"
] ]
}, },
"resolveLoader": { "resolveLoader": {
...@@ -257,124 +300,232 @@ module.exports = { ...@@ -257,124 +300,232 @@ module.exports = {
"output": { "output": {
"path": path.join(process.cwd(), "dist"), "path": path.join(process.cwd(), "dist"),
"filename": "[name].bundle.js", "filename": "[name].bundle.js",
"chunkFilename": "[id].chunk.js" "chunkFilename": "[id].chunk.js",
"crossOriginLoading": false
}, },
"module": { "module": {
"rules": [ "rules": [
{
"enforce": "pre",
"test": /\.(js|ts)$/,
"loader": "source-map-loader",
"exclude": [
/\/node_modules\//,
path.join(__dirname, 'node_modules', '@angular/compiler')
]
},
{ {
"test": /\.html$/, "test": /\.html$/,
"loader": "html-loader" "use": ["html-loader"]
}, },
{ {
"test": /\.(eot|svg)$/, test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2|json|xml|ico|cur|ani)$/,
"loader": "file-loader?name=[name].[hash:20].[ext]" "use": ["file-loader?name=[path][name].[ext]"]
},
{
"test": /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
"loader": "url-loader?name=[name].[hash:20].[ext]&limit=10000"
}, },
{ {
"exclude": style_paths, "exclude": style_paths,
"test": /\.css$/, "test": /\.css$/,
"loaders": [ "use": [
"exports-loader?module.exports.toString()", "exports-loader?module.exports.toString()",
"css-loader?{\"sourceMap\":false,\"importLoaders\":1}", {
"postcss-loader" "loader": "css-loader",
"options": {
"sourceMap": false,
"importLoaders": 1
}
},
{
"loader": "postcss-loader",
"options": {
"ident": "postcss",
"plugins": postcssPlugins
}
}
] ]
}, },
{ {
"exclude": style_paths, "exclude": style_paths,
"test": /\.scss$|\.sass$/, "test": /\.scss$|\.sass$/,
"loaders": [ "use": [
"exports-loader?module.exports.toString()", "exports-loader?module.exports.toString()",
"css-loader?{\"sourceMap\":false,\"importLoaders\":1}", {
"postcss-loader", "loader": "css-loader",
"sass-loader" "options": {
"sourceMap": false,
"importLoaders": 1
}
},
{
"loader": "postcss-loader",
"options": {
"ident": "postcss",
"plugins": postcssPlugins
}
},
{
"loader": "sass-loader",
"options": {
"sourceMap": false,
"precision": 8,
"includePaths": []
}
}
] ]
}, },
{ {
"exclude": style_paths, "exclude": style_paths,
"test": /\.less$/, "test": /\.less$/,
"loaders": [ "use": [
"exports-loader?module.exports.toString()", "exports-loader?module.exports.toString()",
"css-loader?{\"sourceMap\":false,\"importLoaders\":1}", {
"postcss-loader", "loader": "css-loader",
"less-loader" "options": {
"sourceMap": false,
"importLoaders": 1
}
},
{
"loader": "postcss-loader",
"options": {
"ident": "postcss",
"plugins": postcssPlugins
}
},
{
"loader": "less-loader",
"options": {
"sourceMap": false
}
}
] ]
}, },
{ {
"exclude": style_paths, "exclude": style_paths,
"test": /\.styl$/, "test": /\.styl$/,
"loaders": [ "use": [
"exports-loader?module.exports.toString()", "exports-loader?module.exports.toString()",
"css-loader?{\"sourceMap\":false,\"importLoaders\":1}", {
"postcss-loader", "loader": "css-loader",
"stylus-loader?{\"sourceMap\":false,\"paths\":[]}" "options": {
"sourceMap": false,
"importLoaders": 1
}
},
{
"loader": "postcss-loader",
"options": {
"ident": "postcss",
"plugins": postcssPlugins
}
},
{
"loader": "stylus-loader",
"options": {
"sourceMap": false,
"paths": []
}
}
] ]
}, },
{ {
"include": style_paths, "include": style_paths,
"test": /\.css$/, "test": /\.css$/,
"loaders": ExtractTextPlugin.extract({
"use": [ "use": [
"css-loader?{\"sourceMap\":false,\"importLoaders\":1}", "style-loader",
"postcss-loader" {
], "loader": "css-loader",
"fallback": "style-loader", "options": {
"publicPath": "" "sourceMap": false,
}) "importLoaders": 1
}
},
{
"loader": "postcss-loader",
"options": {
"ident": "postcss",
"plugins": postcssPlugins
}
}
]
}, },
{ {
"include": style_paths, "include": style_paths,
"test": /\.scss$|\.sass$/, "test": /\.scss$|\.sass$/,
"loaders": ExtractTextPlugin.extract({
"use": [ "use": [
"css-loader?{\"sourceMap\":false,\"importLoaders\":1}", "style-loader",
"postcss-loader", {
"sass-loader" "loader": "css-loader",
], "options": {
"fallback": "style-loader", "sourceMap": false,
"publicPath": "" "importLoaders": 1
}) }
}, },
{ {
"include": style_paths, "loader": "postcss-loader",
"options": {
"ident": "postcss",
"plugins": postcssPlugins
}
},
{
"loader": "sass-loader",
"options": {
"sourceMap": false,
"precision": 8,
"includePaths": []
}
}
]
},
{
"include":style_paths,
"test": /\.less$/, "test": /\.less$/,
"loaders": ExtractTextPlugin.extract({
"use": [ "use": [
"css-loader?{\"sourceMap\":false,\"importLoaders\":1}", "style-loader",
"postcss-loader", {
"less-loader" "loader": "css-loader",
], "options": {
"fallback": "style-loader", "sourceMap": false,
"publicPath": "" "importLoaders": 1
}) }
},
{
"loader": "postcss-loader",
"options": {
"ident": "postcss",
"plugins": postcssPlugins
}
},
{
"loader": "less-loader",
"options": {
"sourceMap": false
}
}
]
}, },
{ {
"include": style_paths, "include": style_paths,
"test": /\.styl$/, "test": /\.styl$/,
"loaders": ExtractTextPlugin.extract({
"use": [ "use": [
"css-loader?{\"sourceMap\":false,\"importLoaders\":1}", "style-loader",
"postcss-loader", {
"stylus-loader?{\"sourceMap\":false,\"paths\":[]}" "loader": "css-loader",
], "options": {
"fallback": "style-loader", "sourceMap": false,
"publicPath": "" "importLoaders": 1
}) }
},
{
"loader": "postcss-loader",
"options": {
"ident": "postcss",
"plugins": postcssPlugins
}
},
{
"loader": "stylus-loader",
"options": {
"sourceMap": false,
"paths": []
}
}
]
}, },
{ {
"test": /\.ts$/, "test": /\.ts$/,
"loader": "@ngtools/webpack" "use": "@ngtools/webpack"
} }
] ]
}, },
...@@ -391,5 +542,8 @@ module.exports = { ...@@ -391,5 +542,8 @@ module.exports = {
setImmediate: false, setImmediate: false,
__dirname: false, __dirname: false,
__filename: false __filename: false
},
"devServer": {
"historyApiFallback": true
} }
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment