|
|
@ -1,12 +1,16 @@ |
|
|
/* eslint-disable */ |
|
|
/* eslint-disable no-useless-escape */ |
|
|
|
|
|
/* eslint-disable global-require */ |
|
|
|
|
|
|
|
|
const webpack = require('webpack'), path = require('path'); |
|
|
const webpack = require('webpack'); |
|
|
|
|
|
const path = require('path'); |
|
|
|
|
|
|
|
|
const appRoot = path.resolve(__dirname, '..'); |
|
|
const appRoot = path.resolve(__dirname, '..'); |
|
|
|
|
|
|
|
|
function root() { |
|
|
function root() { |
|
|
var newArgs = Array.prototype.slice.call(arguments, 0); |
|
|
// eslint-disable-next-line prefer-rest-params
|
|
|
|
|
|
const newArgs = Array.prototype.slice.call(arguments, 0); |
|
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line prefer-spread
|
|
|
return path.join.apply(path, [appRoot].concat(newArgs)); |
|
|
return path.join.apply(path, [appRoot].concat(newArgs)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -24,7 +28,7 @@ const plugins = { |
|
|
// https://www.npmjs.com/package/@ngtools/webpack
|
|
|
// https://www.npmjs.com/package/@ngtools/webpack
|
|
|
NgToolsWebpack: require('@ngtools/webpack'), |
|
|
NgToolsWebpack: require('@ngtools/webpack'), |
|
|
// https://github.com/NMFR/optimize-css-assets-webpack-plugin
|
|
|
// https://github.com/NMFR/optimize-css-assets-webpack-plugin
|
|
|
OptimizeCSSAssetsPlugin: require("optimize-css-assets-webpack-plugin"), |
|
|
OptimizeCSSAssetsPlugin: require('optimize-css-assets-webpack-plugin'), |
|
|
// https://webpack.js.org/plugins/eslint-webpack-plugin/
|
|
|
// https://webpack.js.org/plugins/eslint-webpack-plugin/
|
|
|
ESLintPlugin: require('eslint-webpack-plugin'), |
|
|
ESLintPlugin: require('eslint-webpack-plugin'), |
|
|
// https://www.npmjs.com/package/sass-lint-webpack
|
|
|
// https://www.npmjs.com/package/sass-lint-webpack
|
|
|
@ -34,10 +38,12 @@ const plugins = { |
|
|
// https://www.npmjs.com/package/@angular-devkit/build-optimizer
|
|
|
// https://www.npmjs.com/package/@angular-devkit/build-optimizer
|
|
|
BuildOptimizerWebpackPlugin: require('@angular-devkit/build-optimizer').BuildOptimizerWebpackPlugin, |
|
|
BuildOptimizerWebpackPlugin: require('@angular-devkit/build-optimizer').BuildOptimizerWebpackPlugin, |
|
|
// https://webpack.js.org/plugins/copy-webpack-plugin/
|
|
|
// https://webpack.js.org/plugins/copy-webpack-plugin/
|
|
|
CopyPlugin: require('copy-webpack-plugin') |
|
|
CopyPlugin: require('copy-webpack-plugin'), |
|
|
|
|
|
// https://www.npmjs.com/package/webpack-filter-warnings-plugin
|
|
|
|
|
|
FilterWarningsPlugin: require('webpack-filter-warnings-plugin'), |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
module.exports = function (env) { |
|
|
module.exports = function calculateConfig(env) { |
|
|
const isDevServer = path.basename(require.main.filename) === 'webpack-dev-server.js'; |
|
|
const isDevServer = path.basename(require.main.filename) === 'webpack-dev-server.js'; |
|
|
const isProduction = env && env.production; |
|
|
const isProduction = env && env.production; |
|
|
const isTests = env && env.target === 'tests'; |
|
|
const isTests = env && env.target === 'tests'; |
|
|
@ -47,23 +53,26 @@ module.exports = function (env) { |
|
|
|
|
|
|
|
|
const configFile = isTests ? 'tsconfig.spec.json' : 'tsconfig.app.json'; |
|
|
const configFile = isTests ? 'tsconfig.spec.json' : 'tsconfig.app.json'; |
|
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
|
|
console.log(`Use ${configFile}`); |
|
|
|
|
|
|
|
|
const config = { |
|
|
const config = { |
|
|
mode: isProduction ? 'production' : 'development', |
|
|
mode: isProduction ? 'production' : 'development', |
|
|
|
|
|
|
|
|
/** |
|
|
/* |
|
|
* Source map for Karma from the help of karma-sourcemap-loader & karma-webpack. |
|
|
* Source map for Karma from the help of karma-sourcemap-loader & karma-webpack. |
|
|
* |
|
|
* |
|
|
* See: https://webpack.js.org/configuration/devtool/
|
|
|
* See: https://webpack.js.org/configuration/devtool/
|
|
|
*/ |
|
|
*/ |
|
|
devtool: isProduction ? false : 'inline-source-map', |
|
|
devtool: isProduction ? false : 'inline-source-map', |
|
|
|
|
|
|
|
|
/** |
|
|
/* |
|
|
* Options affecting the resolving of modules. |
|
|
* Options affecting the resolving of modules. |
|
|
* |
|
|
* |
|
|
* See: https://webpack.js.org/configuration/resolve/
|
|
|
* See: https://webpack.js.org/configuration/resolve/
|
|
|
*/ |
|
|
*/ |
|
|
resolve: { |
|
|
resolve: { |
|
|
/** |
|
|
/* |
|
|
* An array of extensions that should be used to resolve modules. |
|
|
* An array of extensions that should be used to resolve modules. |
|
|
* |
|
|
* |
|
|
* See: https://webpack.js.org/configuration/resolve/#resolve-extensions
|
|
|
* See: https://webpack.js.org/configuration/resolve/#resolve-extensions
|
|
|
@ -72,88 +81,89 @@ module.exports = function (env) { |
|
|
modules: [ |
|
|
modules: [ |
|
|
root('app'), |
|
|
root('app'), |
|
|
root('app', 'theme'), |
|
|
root('app', 'theme'), |
|
|
root('node_modules') |
|
|
root('node_modules'), |
|
|
], |
|
|
], |
|
|
|
|
|
|
|
|
plugins: [ |
|
|
plugins: [ |
|
|
new plugins.TsconfigPathsPlugin({ |
|
|
new plugins.TsconfigPathsPlugin({ |
|
|
configFile |
|
|
configFile, |
|
|
}) |
|
|
}), |
|
|
] |
|
|
], |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/* |
|
|
* Options affecting the normal modules. |
|
|
* Options affecting the normal modules. |
|
|
* |
|
|
* |
|
|
* See: https://webpack.js.org/configuration/module/
|
|
|
* See: https://webpack.js.org/configuration/module/
|
|
|
*/ |
|
|
*/ |
|
|
module: { |
|
|
module: { |
|
|
/** |
|
|
/* |
|
|
* An array of Rules which are matched to requests when modules are created. |
|
|
* An array of Rules which are matched to requests when modules are created. |
|
|
* |
|
|
* |
|
|
* See: https://webpack.js.org/configuration/module/#module-rules
|
|
|
* See: https://webpack.js.org/configuration/module/#module-rules
|
|
|
*/ |
|
|
*/ |
|
|
rules: [{ |
|
|
rules: [{ |
|
|
test: /\.mjs$/, |
|
|
test: /\.mjs$/, |
|
|
type: "javascript/auto", |
|
|
type: 'javascript/auto', |
|
|
include: [/node_modules/] |
|
|
include: [/node_modules/], |
|
|
}, { |
|
|
}, { |
|
|
|
|
|
// Mark files inside `@angular/core` as using SystemJS style dynamic imports.
|
|
|
test: /[\/\\]@angular[\/\\]core[\/\\].+\.js$/, |
|
|
test: /[\/\\]@angular[\/\\]core[\/\\].+\.js$/, |
|
|
parser: { system: true }, |
|
|
parser: { system: true }, |
|
|
include: [/node_modules/] |
|
|
include: [/node_modules/], |
|
|
}, { |
|
|
}, { |
|
|
test: /\.js\.flow$/, |
|
|
test: /\.js\.flow$/, |
|
|
use: [{ |
|
|
use: [{ |
|
|
loader: 'ignore-loader' |
|
|
loader: 'ignore-loader', |
|
|
}], |
|
|
}], |
|
|
include: [/node_modules/] |
|
|
include: [/node_modules/], |
|
|
}, { |
|
|
}, { |
|
|
test: /\.map$/, |
|
|
test: /\.map$/, |
|
|
use: [{ |
|
|
use: [{ |
|
|
loader: 'ignore-loader' |
|
|
loader: 'ignore-loader', |
|
|
}], |
|
|
}], |
|
|
include: [/node_modules/] |
|
|
include: [/node_modules/], |
|
|
}, { |
|
|
}, { |
|
|
test: /\.d\.ts$/, |
|
|
test: /\.d\.ts$/, |
|
|
use: [{ |
|
|
use: [{ |
|
|
loader: 'ignore-loader' |
|
|
loader: 'ignore-loader', |
|
|
}], |
|
|
}], |
|
|
include: [/node_modules/] |
|
|
include: [/node_modules/], |
|
|
}, { |
|
|
}, { |
|
|
test: /\.(woff|woff2|ttf|eot)(\?.*$|$)/, |
|
|
test: /\.(woff|woff2|ttf|eot)(\?.*$|$)/, |
|
|
use: [{ |
|
|
use: [{ |
|
|
loader: 'file-loader?name=[name].[hash].[ext]', |
|
|
loader: 'file-loader?name=[name].[fullhash].[ext]', |
|
|
options: { |
|
|
options: { |
|
|
outputPath: 'assets', |
|
|
outputPath: 'assets', |
|
|
/* |
|
|
/* |
|
|
* Use custom public path as ./ is not supported by fonts. |
|
|
* Use custom public path as ./ is not supported by fonts. |
|
|
*/ |
|
|
*/ |
|
|
publicPath: isDevServer ? undefined : 'assets' |
|
|
publicPath: isDevServer ? undefined : 'assets', |
|
|
} |
|
|
}, |
|
|
}] |
|
|
}], |
|
|
}, { |
|
|
}, { |
|
|
test: /\.(png|jpe?g|gif|svg|ico)(\?.*$|$)/, |
|
|
test: /\.(png|jpe?g|gif|svg|ico)(\?.*$|$)/, |
|
|
use: [{ |
|
|
use: [{ |
|
|
loader: 'file-loader?name=[name].[hash].[ext]', |
|
|
loader: 'file-loader?name=[name].[fullhash].[ext]', |
|
|
options: { |
|
|
options: { |
|
|
outputPath: 'assets' |
|
|
outputPath: 'assets', |
|
|
} |
|
|
}, |
|
|
}] |
|
|
}], |
|
|
}, { |
|
|
}, { |
|
|
test: /\.css$/, |
|
|
test: /\.css$/, |
|
|
use: [ |
|
|
use: [ |
|
|
plugins.MiniCssExtractPlugin.loader, |
|
|
plugins.MiniCssExtractPlugin.loader, |
|
|
{ |
|
|
{ |
|
|
loader: 'css-loader' |
|
|
loader: 'css-loader', |
|
|
}, { |
|
|
}, { |
|
|
loader: 'postcss-loader' |
|
|
loader: 'postcss-loader', |
|
|
}] |
|
|
}], |
|
|
}, { |
|
|
}, { |
|
|
test: /\.scss$/, |
|
|
test: /\.scss$/, |
|
|
use: [{ |
|
|
use: [{ |
|
|
loader: 'raw-loader' |
|
|
loader: 'raw-loader', |
|
|
}, { |
|
|
}, { |
|
|
loader: 'postcss-loader' |
|
|
loader: 'postcss-loader', |
|
|
}, { |
|
|
}, { |
|
|
loader: 'sass-loader', |
|
|
loader: 'sass-loader', |
|
|
options: { |
|
|
options: { |
|
|
@ -162,52 +172,67 @@ module.exports = function (env) { |
|
|
@import '_mixins'; |
|
|
@import '_mixins'; |
|
|
`,
|
|
|
`,
|
|
|
sassOptions: { |
|
|
sassOptions: { |
|
|
includePaths: [root('app', 'theme')] |
|
|
includePaths: [root('app', 'theme')], |
|
|
} |
|
|
}, |
|
|
} |
|
|
}, |
|
|
}], |
|
|
}], |
|
|
exclude: root('app', 'theme') |
|
|
exclude: root('app', 'theme'), |
|
|
}] |
|
|
}], |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
plugins: [ |
|
|
plugins: [ |
|
|
new webpack.ContextReplacementPlugin(/\@angular(\\|\/)core(\\|\/)fesm5/, root('./app'), {}), |
|
|
new plugins.FilterWarningsPlugin({ |
|
|
|
|
|
exclude: /System.import/, |
|
|
|
|
|
}), |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* Always replace the context for the System.import in angular/core to prevent warnings. |
|
|
|
|
|
*/ |
|
|
|
|
|
new webpack.ContextReplacementPlugin( |
|
|
|
|
|
/\@angular(\\|\/)core(\\|\/)/, |
|
|
|
|
|
root('./app', '$_lazy_route_resources'), |
|
|
|
|
|
{}, |
|
|
|
|
|
), |
|
|
|
|
|
|
|
|
/** |
|
|
/* |
|
|
* Puts each bundle into a file and appends the hash of the file to the path. |
|
|
* Puts each bundle into a file and appends the hash of the file to the path. |
|
|
* |
|
|
* |
|
|
* See: https://github.com/webpack-contrib/mini-css-extract-plugin
|
|
|
* See: https://github.com/webpack-contrib/mini-css-extract-plugin
|
|
|
*/ |
|
|
*/ |
|
|
new plugins.MiniCssExtractPlugin({ |
|
|
new plugins.MiniCssExtractPlugin({ |
|
|
filename: '[name].css' |
|
|
filename: '[name].css', |
|
|
}), |
|
|
}), |
|
|
|
|
|
|
|
|
new webpack.LoaderOptionsPlugin({ |
|
|
new webpack.LoaderOptionsPlugin({ |
|
|
options: { |
|
|
options: { |
|
|
htmlLoader: { |
|
|
htmlLoader: { |
|
|
/** |
|
|
/* |
|
|
* Define the root for images, so that we can use absolute urls. |
|
|
* Define the root for images, so that we can use absolute urls. |
|
|
* |
|
|
* |
|
|
* See: https://github.com/webpack/html-loader#Advanced_Options
|
|
|
* See: https://github.com/webpack/html-loader#Advanced_Options
|
|
|
*/ |
|
|
*/ |
|
|
root: root('app', 'images') |
|
|
root: root('app', 'images'), |
|
|
}, |
|
|
}, |
|
|
context: '/' |
|
|
context: '/', |
|
|
} |
|
|
}, |
|
|
}), |
|
|
}), |
|
|
|
|
|
|
|
|
new plugins.SassLintPlugin(), |
|
|
new plugins.SassLintPlugin(), |
|
|
|
|
|
|
|
|
/** |
|
|
/* |
|
|
* Detect circular dependencies in app. |
|
|
* Detect circular dependencies in app. |
|
|
* |
|
|
* |
|
|
* See: https://github.com/aackerman/circular-dependency-plugin
|
|
|
* See: https://github.com/aackerman/circular-dependency-plugin
|
|
|
*/ |
|
|
*/ |
|
|
new plugins.CircularDependencyPlugin({ |
|
|
new plugins.CircularDependencyPlugin({ |
|
|
exclude: /([\\\/]node_modules[\\\/])|(ngfactory\.js$)/, |
|
|
exclude: /([\\\/]node_modules[\\\/])|(ngfactory\.js$)/, |
|
|
// Add errors to webpack instead of warnings
|
|
|
// Add errors to webpack instead of warnings
|
|
|
failOnError: true |
|
|
failOnError: true, |
|
|
}), |
|
|
}), |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* Copy lazy loaded libraries to output. |
|
|
|
|
|
*/ |
|
|
new plugins.CopyPlugin({ |
|
|
new plugins.CopyPlugin({ |
|
|
patterns: [ |
|
|
patterns: [ |
|
|
{ from: './node_modules/simplemde/dist', to: 'dependencies/simplemde' }, |
|
|
{ from: './node_modules/simplemde/dist', to: 'dependencies/simplemde' }, |
|
|
@ -225,11 +250,11 @@ module.exports = function (env) { |
|
|
{ from: './node_modules/tinymce/tinymce.min.js', to: 'dependencies/tinymce' }, |
|
|
{ from: './node_modules/tinymce/tinymce.min.js', to: 'dependencies/tinymce' }, |
|
|
|
|
|
|
|
|
{ from: './node_modules/ace-builds/src-min/ace.js', to: 'dependencies/ace/ace.js' }, |
|
|
{ from: './node_modules/ace-builds/src-min/ace.js', to: 'dependencies/ace/ace.js' }, |
|
|
|
|
|
{ from: './node_modules/ace-builds/src-min/ext-language_tools.js', to: 'dependencies/ace/ext/language_tools.js' }, |
|
|
|
|
|
{ from: './node_modules/ace-builds/src-min/ext-modelist.js', to: 'dependencies/ace/ext/modelist.js' }, |
|
|
{ from: './node_modules/ace-builds/src-min/mode-*.js', to: 'dependencies/ace/[name].[ext]' }, |
|
|
{ from: './node_modules/ace-builds/src-min/mode-*.js', to: 'dependencies/ace/[name].[ext]' }, |
|
|
{ from: './node_modules/ace-builds/src-min/worker-*.js', to: 'dependencies/ace/[name].[ext]' }, |
|
|
|
|
|
{ from: './node_modules/ace-builds/src-min/snippets', to: 'dependencies/ace/snippets' }, |
|
|
{ from: './node_modules/ace-builds/src-min/snippets', to: 'dependencies/ace/snippets' }, |
|
|
{ from: './node_modules/ace-builds/src-min/ext-modelist.js', to: 'dependencies/ace/ext/modelist.js' }, |
|
|
{ from: './node_modules/ace-builds/src-min/worker-*.js', to: 'dependencies/ace/[name].[ext]' }, |
|
|
{ from: './node_modules/ace-builds/src-min/ext-language_tools.js', to: 'dependencies/ace/ext/language_tools.js' }, |
|
|
|
|
|
|
|
|
|
|
|
{ from: './node_modules/video.js/dist/video.min.js', to: 'dependencies/videojs' }, |
|
|
{ from: './node_modules/video.js/dist/video.min.js', to: 'dependencies/videojs' }, |
|
|
{ from: './node_modules/video.js/dist/video-js.min.css', to: 'dependencies/videojs' }, |
|
|
{ from: './node_modules/video.js/dist/video-js.min.css', to: 'dependencies/videojs' }, |
|
|
@ -244,27 +269,27 @@ module.exports = function (env) { |
|
|
|
|
|
|
|
|
devServer: { |
|
|
devServer: { |
|
|
headers: { |
|
|
headers: { |
|
|
'Access-Control-Allow-Origin': '*' |
|
|
'Access-Control-Allow-Origin': '*', |
|
|
}, |
|
|
}, |
|
|
historyApiFallback: true, |
|
|
historyApiFallback: true, |
|
|
} |
|
|
}, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if (!isTests) { |
|
|
if (!isTests) { |
|
|
/** |
|
|
/* |
|
|
* The entry point for the bundle. Our Angular app. |
|
|
* The entry point for the bundle. Our Angular app. |
|
|
* |
|
|
* |
|
|
* See: https://webpack.js.org/configuration/entry-context/
|
|
|
* See: https://webpack.js.org/configuration/entry-context/
|
|
|
*/ |
|
|
*/ |
|
|
config.entry = { |
|
|
config.entry = { |
|
|
'shims': './app/shims.ts', |
|
|
shims: './app/shims.ts', |
|
|
'style': './app/style.js', |
|
|
style: './app/style.js', |
|
|
'app': './app/app.ts' |
|
|
app: './app/app.ts', |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if (isProduction) { |
|
|
if (isProduction) { |
|
|
config.output = { |
|
|
config.output = { |
|
|
/** |
|
|
/* |
|
|
* The output directory as absolute path (required). |
|
|
* The output directory as absolute path (required). |
|
|
* |
|
|
* |
|
|
* See: https://webpack.js.org/configuration/output/#output-path
|
|
|
* See: https://webpack.js.org/configuration/output/#output-path
|
|
|
@ -273,38 +298,39 @@ module.exports = function (env) { |
|
|
|
|
|
|
|
|
publicPath: './build/', |
|
|
publicPath: './build/', |
|
|
|
|
|
|
|
|
/** |
|
|
/* |
|
|
* Specifies the name of each output file on disk. |
|
|
* Specifies the name of each output file on disk. |
|
|
* |
|
|
* |
|
|
* See: https://webpack.js.org/configuration/output/#output-filename
|
|
|
* See: https://webpack.js.org/configuration/output/#output-filename
|
|
|
*/ |
|
|
*/ |
|
|
filename: '[name].js', |
|
|
filename: '[name].js', |
|
|
|
|
|
|
|
|
/** |
|
|
/* |
|
|
* The filename of non-entry chunks as relative path inside the output.path directory. |
|
|
* The filename of non-entry chunks as relative path inside the output.path directory. |
|
|
* |
|
|
* |
|
|
* See: https://webpack.js.org/configuration/output/#output-chunkfilename
|
|
|
* See: https://webpack.js.org/configuration/output/#output-chunkfilename
|
|
|
*/ |
|
|
*/ |
|
|
chunkFilename: '[id].[hash].chunk.js' |
|
|
chunkFilename: '[id].[fullhash].chunk.js', |
|
|
}; |
|
|
}; |
|
|
} else { |
|
|
} else { |
|
|
config.output = { |
|
|
config.output = { |
|
|
filename: '[name].js', |
|
|
filename: '[name].js', |
|
|
|
|
|
|
|
|
/** |
|
|
/* |
|
|
* Set the public path, because we are running the website from another port (5000). |
|
|
* Set the public path, because we are running the website from another port (5000). |
|
|
*/ |
|
|
*/ |
|
|
publicPath: 'https://localhost:3000/' |
|
|
publicPath: 'https://localhost:3000/', |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
config.plugins.push( |
|
|
config.plugins.push( |
|
|
new plugins.HtmlWebpackPlugin({ |
|
|
new plugins.HtmlWebpackPlugin({ |
|
|
|
|
|
filename: 'index.html', |
|
|
hash: true, |
|
|
hash: true, |
|
|
chunks: ['shims', 'app'], |
|
|
chunks: ['shims', 'app'], |
|
|
chunksSortMode: 'manual', |
|
|
chunksSortMode: 'manual', |
|
|
template: 'app/index.html' |
|
|
template: root('app', 'index.html'), |
|
|
}) |
|
|
}), |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
config.plugins.push( |
|
|
config.plugins.push( |
|
|
@ -313,30 +339,28 @@ module.exports = function (env) { |
|
|
hash: true, |
|
|
hash: true, |
|
|
chunks: ['style'], |
|
|
chunks: ['style'], |
|
|
chunksSortMode: 'none', |
|
|
chunksSortMode: 'none', |
|
|
template: 'app/_theme.html' |
|
|
template: root('app', '_theme.html'), |
|
|
}) |
|
|
}), |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
if (isProduction) { |
|
|
if (isProduction) { |
|
|
config.plugins.push( |
|
|
config.plugins.push( |
|
|
new plugins.ESLintPlugin({ |
|
|
new plugins.ESLintPlugin({ |
|
|
files: [ |
|
|
files: [ |
|
|
'./app/**/*.ts' |
|
|
'./app/**/*.ts', |
|
|
] |
|
|
], |
|
|
}) |
|
|
}), |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!isTestCoverage) { |
|
|
if (!isTestCoverage) { |
|
|
config.plugins.push( |
|
|
config.plugins.push( |
|
|
new plugins.NgToolsWebpack.AngularCompilerPlugin({ |
|
|
new plugins.NgToolsWebpack.AngularWebpackPlugin({ |
|
|
directTemplateLoading: true, |
|
|
directTemplateLoading: true, |
|
|
entryModule: 'app/app.module#AppModule', |
|
|
jitMode: !isAot, |
|
|
skipCodeGeneration: !isAot, |
|
|
tsconfig: configFile, |
|
|
sourceMap: !isProduction, |
|
|
}), |
|
|
tsConfigPath: configFile |
|
|
|
|
|
}) |
|
|
|
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -349,19 +373,19 @@ module.exports = function (env) { |
|
|
ecma: 5, |
|
|
ecma: 5, |
|
|
mangle: true, |
|
|
mangle: true, |
|
|
output: { |
|
|
output: { |
|
|
comments: false |
|
|
comments: false, |
|
|
}, |
|
|
}, |
|
|
safari10: true |
|
|
safari10: true, |
|
|
}, |
|
|
}, |
|
|
extractComments: true |
|
|
extractComments: true, |
|
|
}), |
|
|
}), |
|
|
|
|
|
|
|
|
new plugins.OptimizeCSSAssetsPlugin({}) |
|
|
new plugins.OptimizeCSSAssetsPlugin({}), |
|
|
] |
|
|
], |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
config.performance = { |
|
|
config.performance = { |
|
|
hints: false |
|
|
hints: false, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
config.plugins.push(new plugins.BuildOptimizerWebpackPlugin()); |
|
|
config.plugins.push(new plugins.BuildOptimizerWebpackPlugin()); |
|
|
@ -371,9 +395,9 @@ module.exports = function (env) { |
|
|
use: [{ |
|
|
use: [{ |
|
|
loader: '@angular-devkit/build-optimizer/webpack-loader', |
|
|
loader: '@angular-devkit/build-optimizer/webpack-loader', |
|
|
options: { |
|
|
options: { |
|
|
sourceMap: false |
|
|
sourceMap: false, |
|
|
} |
|
|
}, |
|
|
}] |
|
|
}], |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -382,7 +406,7 @@ module.exports = function (env) { |
|
|
config.module.rules.push({ |
|
|
config.module.rules.push({ |
|
|
test: /\.ts$/, |
|
|
test: /\.ts$/, |
|
|
use: [{ |
|
|
use: [{ |
|
|
loader: 'ts-loader' |
|
|
loader: 'ts-loader', |
|
|
}], |
|
|
}], |
|
|
include: [/\.(e2e|spec)\.ts$/], |
|
|
include: [/\.(e2e|spec)\.ts$/], |
|
|
}); |
|
|
}); |
|
|
@ -391,19 +415,19 @@ module.exports = function (env) { |
|
|
config.module.rules.push({ |
|
|
config.module.rules.push({ |
|
|
test: /\.ts$/, |
|
|
test: /\.ts$/, |
|
|
use: [{ |
|
|
use: [{ |
|
|
loader: 'istanbul-instrumenter-loader?esModules=true' |
|
|
loader: 'istanbul-instrumenter-loader?esModules=true', |
|
|
}, { |
|
|
}, { |
|
|
loader: 'ts-loader' |
|
|
loader: 'ts-loader', |
|
|
}], |
|
|
}], |
|
|
exclude: [/\.(e2e|spec)\.ts$/] |
|
|
exclude: [/\.(e2e|spec)\.ts$/], |
|
|
}); |
|
|
}); |
|
|
} else { |
|
|
} else { |
|
|
config.module.rules.push({ |
|
|
config.module.rules.push({ |
|
|
test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/, |
|
|
test: /\.[jt]sx?$/, |
|
|
use: [{ |
|
|
use: [{ |
|
|
loader: plugins.NgToolsWebpack.NgToolsLoader |
|
|
loader: '@ngtools/webpack', |
|
|
}] |
|
|
}], |
|
|
}) |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (isProduction) { |
|
|
if (isProduction) { |
|
|
@ -411,17 +435,17 @@ module.exports = function (env) { |
|
|
test: /\.scss$/, |
|
|
test: /\.scss$/, |
|
|
/* |
|
|
/* |
|
|
* Extract the content from a bundle to a file. |
|
|
* Extract the content from a bundle to a file. |
|
|
* |
|
|
* |
|
|
* See: https://github.com/webpack-contrib/extract-text-webpack-plugin
|
|
|
* See: https://github.com/webpack-contrib/extract-text-webpack-plugin
|
|
|
*/ |
|
|
*/ |
|
|
use: [ |
|
|
use: [ |
|
|
plugins.MiniCssExtractPlugin.loader, |
|
|
plugins.MiniCssExtractPlugin.loader, |
|
|
{ |
|
|
{ |
|
|
loader: 'css-loader' |
|
|
loader: 'css-loader', |
|
|
}, { |
|
|
}, { |
|
|
loader: 'postcss-loader' |
|
|
loader: 'postcss-loader', |
|
|
}, { |
|
|
}, { |
|
|
loader: 'sass-loader' |
|
|
loader: 'sass-loader', |
|
|
}], |
|
|
}], |
|
|
/* |
|
|
/* |
|
|
* Do not include component styles. |
|
|
* Do not include component styles. |
|
|
@ -432,21 +456,21 @@ module.exports = function (env) { |
|
|
config.module.rules.push({ |
|
|
config.module.rules.push({ |
|
|
test: /\.scss$/, |
|
|
test: /\.scss$/, |
|
|
use: [{ |
|
|
use: [{ |
|
|
loader: 'style-loader' |
|
|
loader: 'style-loader', |
|
|
}, { |
|
|
}, { |
|
|
loader: 'css-loader' |
|
|
loader: 'css-loader', |
|
|
}, { |
|
|
}, { |
|
|
loader: 'postcss-loader' |
|
|
loader: 'postcss-loader', |
|
|
}, { |
|
|
}, { |
|
|
loader: 'sass-loader', |
|
|
loader: 'sass-loader', |
|
|
options: { |
|
|
options: { |
|
|
sourceMap: true |
|
|
sourceMap: true, |
|
|
} |
|
|
}, |
|
|
}], |
|
|
}], |
|
|
/* |
|
|
/* |
|
|
* Do not include component styles. |
|
|
* Do not include component styles. |
|
|
*/ |
|
|
*/ |
|
|
include: root('app', 'theme') |
|
|
include: root('app', 'theme'), |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -455,4 +479,4 @@ module.exports = function (env) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return config; |
|
|
return config; |
|
|
}; |
|
|
}; |
|
|
|