I’m working with a project created a few time ago, it’s an old version and at the moment is not possible to update it to the latest version, so, I’m updating the main libraries to try to make it faster.
When I updated the webpack and a few other dependencies I started receiving this next error
ERROR in main
Module not found: Error: Can't resolve './src' in 'D:proyectosadmos'
resolve './src' in 'D:proyectosadmos'
using description file: D:proyectosadmospackage.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
using description file: D:proyectosadmospackage.json (relative path: ./src)
no extension
Field 'browser' doesn't contain a valid alias configuration
D:proyectosadmossrc is not a file
.js
Field 'browser' doesn't contain a valid alias configuration
D:proyectosadmossrc.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
D:proyectosadmossrc.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
D:proyectosadmossrc.wasm doesn't exist
as directory
existing directory D:proyectosadmossrc
using description file: D:proyectosadmospackage.json (relative path: ./src)
using path: D:proyectosadmossrcindex
using description file: D:proyectosadmospackage.json (relative path: ./src/index)
no extension
Field 'browser' doesn't contain a valid alias configuration
D:proyectosadmossrcindex doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
D:proyectosadmossrcindex.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
D:proyectosadmossrcindex.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
D:proyectosadmossrcindex.wasm doesn't exist
What I did? starting from the angular.json file
"architect": {}
replaced by
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
"path": "./webpack/webpack.common.js",
"mergeStrategies": { "module.rules": "prepend" }
},
"outputPath": "build/resources/main/META-INF/resources",
"index": "src/main/webapp/index.html",
"main": "src/main/webapp/app/app.main.ts",
"polyfills": "src/main/webapp/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"assets": [
"src/main/webapp/content",
"src/main/webapp/favicon.ico",
"src/main/webapp/manifest.webapp",
{
"glob": "**/*",
"input": "./node_modules/swagger-ui-dist/",
"output": "/swagger-ui/"
}
],
"styles": [
"src/main/webapp/content/scss/global.scss"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/main/webapp/environments/environment.ts",
"with": "src/main/webapp/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
}
},
"serve": {
"builder": "@angular-builders/custom-webpack:dev-server",
"options": {
"browserTarget": "admos:build"
},
"configurations": {
"production": {
"browserTarget": "admos:build:production"
},
"development": {
"browserTarget": "admos:build:development"
}
}
}
}
on the package.json
"scripts":{
"build": "npm run webpack:prod",
"clean-www": "rimraf build/resources/main/META-INF/resourcesapp/{src,build/}",
"cleanup": "rimraf build/resources/main/META-INF/resources",
"postinstall": "ngcc",
"ngc": "ngc -p tsconfig.app.json",
"prettier:format": "prettier --write "{,src/**/}*.{md,json,ts,css,scss,yml}"",
"serve": "npm run start",
"start": "npm run webpack:dev",
"start-tls": "npm run webpack:dev -- --env.tls",
"test": "npm run lint && jest --coverage --logHeapUsage -w=2 --config src/test/javascript/jest.conf.js",
"test:watch": "npm run test -- --watch",
"webpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js",
"webpack-dev-server": "node --max_old_space_size=4096 node_modules/webpack-dev-server/bin/webpack-dev-server.js",
"webpack:build": "npm run cleanup && npm run webpack:build:main",
"webpack:build:main": "npm run webpack -- --config webpack/webpack.dev.js --env.stats=minimal",
"webpack:dev": "npm run webpack-dev-server -- --config webpack/webpack.dev.js --inline --hot --port=9060 --watch-content-base --env.stats=minimal",
"webpack:dev-verbose": "npm run webpack-dev-server -- --config webpack/webpack.dev.js --inline --hot --port=9060 --watch-content-base --profile --progress --env.stats=normal",
"webpack:prod": "npm run cleanup && npm run webpack:prod:main && npm run clean-www",
"webpack:test": "npm run test"
}
replaced with
"scripts":{
"build": "webpack --mode production",
"clean-www": "rimraf build/resources/main/META-INF/resourcesapp/{src,build/}",
"cleanup": "rimraf build/resources/main/META-INF/resources",
"postinstall": "ngcc",
"ngc": "ngc -p tsconfig.app.json",
"prettier:format": "prettier --write "{,src/**/}*.{md,json,ts,css,scss,yml}"",
"serve": "npm run start",
"start": "webpack serve --mode development",
"start-tls": "npm run webpack:dev -- --env.tls",
"test": "npm run lint && jest --coverage --logHeapUsage -w=2 --config src/test/javascript/jest.conf.js",
"test:watch": "npm run test -- --watch",
"webpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js",
"webpack-dev-server": "node --max_old_space_size=4096 node_modules/webpack-dev-server/bin/webpack-dev-server.js",
"webpack:build": "npm run cleanup && npm run webpack:build:main",
"webpack:build:main": "npm run webpack -- --config webpack/webpack.dev.js --env.stats=minimal",
"webpack:dev": "npm run webpack-dev-server -- --config webpack/webpack.prod.js --inline --hot --port=9060 --watch-content-base --env.stats=minimal",
"webpack:dev-verbose": "npm run webpack-dev-server -- --config webpack/webpack.dev.js --inline --hot --port=9060 --watch-content-base --profile --progress --env.stats=normal",
"webpack:prod": "npm run cleanup && npm run webpack:prod:main && npm run clean-www",
"webpack:test": "npm run test"
}
my dependencies were the next
"dependencies": {
"@angular/animations": "11.2.14",
"@angular/cdk": "11.2.13",
"@angular/common": "11.2.14",
"@angular/compiler": "11.2.14",
"@angular/core": "11.2.14",
"@angular/forms": "11.2.14",
"@angular/localize": "11.2.14",
"@angular/platform-browser": "11.2.14",
"@angular/platform-browser-dynamic": "11.2.14",
"@angular/router": "11.2.14",
"@fortawesome/angular-fontawesome": "^0.8.2",
"@fortawesome/fontawesome-svg-core": "1.2.36",
"@fortawesome/free-solid-svg-icons": "5.13.1",
"@ng-bootstrap/ng-bootstrap": "^9.1.3",
"@ng-select/ng-select": "6.1.0",
"@ngx-translate/core": "12.1.2",
"@ngx-translate/http-loader": "5.0.0",
"bootstrap": "4.6.1",
"lodash": "^4.17.21",
"moment": "^2.30.1",
"ng-jhipster": "0.16.0",
"ng2-dragula": "^2.1.1",
"ngx-cookie-service": "10.1.1",
"ngx-infinite-scroll": "9.1.0",
"ngx-pagination": "^5.1.1",
"ngx-spinner": "^10.0.1",
"ngx-webstorage": "7.0.1",
"rxjs": "6.6.7",
"swagger-ui-dist": "3.52.5",
"tslib": "^2.6.3",
"zone.js": "0.11.5"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1102.19",
"@angular/cli": "11.2.19",
"@angular/compiler-cli": "11.2.14",
"@ngtools/webpack": "11.2.19",
"@openapitools/openapi-generator-cli": "1.0.18-4.3.1",
"@types/jest": "26.0.24",
"@types/lodash": "^4.17.5",
"@types/node": "13.13.52",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "2.34.0",
"@typescript-eslint/eslint-plugin-tslint": "2.34.0",
"@typescript-eslint/parser": "2.34.0",
"autoprefixer": "9.8.8",
"browser-sync": "^2.29.1",
"browser-sync-webpack-plugin": "2.3.0",
"codelyzer": "^6.0.0",
"copy-webpack-plugin": "6.0.2",
"css-loader": "3.6.0",
"eslint": "6.8.0",
"eslint-config-jhipster": "0.0.1",
"eslint-config-prettier": "6.11.0",
"eslint-loader": "4.0.2",
"file-loader": "6.2.0",
"friendly-errors-webpack-plugin": "1.7.0",
"generator-jhipster": "6.10.5",
"generator-jhipster-quarkus": "1.1.1",
"html-loader": "1.3.2",
"lint-staged": "8.2.1",
"mini-css-extract-plugin": "0.12.0",
"moment-locales-webpack-plugin": "1.2.0",
"optimize-css-assets-webpack-plugin": "5.0.8",
"postcss-loader": "3.0.0",
"prettier": "2.6.2",
"rimraf": "3.0.2",
"sass-loader": "8.0.2",
"simple-progress-webpack-plugin": "1.1.2",
"style-loader": "1.3.0",
"thread-loader": "2.1.3",
"to-string-loader": "1.2.0",
"ts-loader": "7.0.5",
"tslint": "6.1.3",
"typescript": "4.1.6",
"webpack": "4.46.0",
"webpack-bundle-analyzer": "3.9.0",
"webpack-cli": "3.3.12",
"webpack-dev-server": "3.11.3",
"webpack-merge": "4.2.2",
"webpack-notifier": "1.15.0",
"workbox-webpack-plugin": "5.1.4",
"write-file-webpack-plugin": "4.5.1"
},
and updated to
"dependencies": {
"@angular/animations": "13.2.4",
"@angular/cdk": "13.2.4",
"@angular/common": "13.2.4",
"@angular/compiler": "13.2.4",
"@angular/core": "13.2.4",
"@angular/forms": "13.2.4",
"@angular/localize": "13.2.4",
"@angular/platform-browser": "13.2.4",
"@angular/platform-browser-dynamic": "13.2.4",
"@angular/router": "13.2.4",
"@fortawesome/angular-fontawesome": "^0.10.2",
"@fortawesome/fontawesome-svg-core": "^1.3.0",
"@fortawesome/free-solid-svg-icons": "^6.0.0",
"@ng-bootstrap/ng-bootstrap": "^11.0.0",
"@ng-select/ng-select": "8.3.0",
"@ngx-translate/core": "^14.0.0",
"@ngx-translate/http-loader": "^7.0.0",
"bootstrap": "4.6.1",
"lodash": "^4.17.21",
"moment": "^2.30.1",
"@augwit/ng-jhipster": "0.20.9",
"ng2-dragula": "^2.1.1",
"ngx-cookie-service": "13.2.1",
"ngx-infinite-scroll": "9.1.0",
"ngx-pagination": "^5.1.1",
"ngx-spinner": "^13.1.1",
"ngx-webstorage": "9.0.0",
"rxjs": "6.6.7",
"swagger-ui-dist": "3.52.5",
"tslib": "^2.6.3",
"zone.js": "0.11.5"
},
"devDependencies": {
"@angular-devkit/build-angular": "13.2.4",
"@angular/cli": "11.2.19",
"@angular/compiler-cli": "13.2.4",
"@ngtools/webpack": "13.2.4",
"@openapitools/openapi-generator-cli": "1.0.18-4.3.1",
"@types/jest": "26.0.24",
"@types/lodash": "^4.17.5",
"@types/node": "13.13.52",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/eslint-plugin-tslint": "3.2.0",
"@typescript-eslint/parser": "^4.0.0",
"autoprefixer": "9.8.8",
"browser-sync": "^2.29.1",
"browser-sync-webpack-plugin": "2.3.0",
"codelyzer": "^6.0.0",
"copy-webpack-plugin": "6.0.2",
"css-loader": "3.6.0",
"eslint": "^7.32.0",
"@upside-cloud/eslint-config-jhipster": "0.12.1",
"eslint-config-prettier": "^6.15.0",
"eslint-loader": "4.0.2",
"file-loader": "6.2.0",
"@soda/friendly-errors-webpack-plugin": "1.8.1",
"generator-jhipster": "6.10.5",
"generator-jhipster-quarkus": "1.1.1",
"html-loader": "1.3.2",
"lint-staged": "8.2.1",
"mini-css-extract-plugin": "0.12.0",
"moment-locales-webpack-plugin": "1.2.0",
"css-minimizer-webpack-plugin": "6.0.0",
"postcss-loader": "3.0.0",
"prettier": "2.6.2",
"rimraf": "3.0.2",
"sass-loader": "8.0.2",
"simple-progress-webpack-plugin": "1.1.2",
"style-loader": "1.3.0",
"thread-loader": "3.0.4",
"to-string-loader": "1.2.0",
"ts-loader": "7.0.5",
"tslint": "6.1.3",
"typescript": "4.4.3",
"webpack": "^5.30.0",
"webpack-bundle-analyzer": "3.9.0",
"webpack-cli": "4.10.0",
"webpack-dev-server": "3.11.3",
"webpack-merge": "4.2.2",
"webpack-notifier": "1.15.0",
"workbox-webpack-plugin": "6.6.0",
"@angular-builders/custom-webpack":"13.1.0",
"write-file-webpack-plugin": "4.5.1"
},
next thing I did was update tsconfig.base.json
"compilerOptions": {
"target": "es6",
"module": "esnext",
"moduleResolution": "node",
"sourceMap": true,
"suppressImplicitAnyIndexErrors": true,
"skipLibCheck": true,
"outDir": "build/resources/main/META-INF/resourcesapp",
"lib": ["es7", "dom", "ES2019.Object"],
"baseUrl": "./",
"paths": {
"app/*": ["src/main/webapp/app/*"]
},
to the next
"compilerOptions": {
"target": "es2015",
"module": "esnext",
"moduleResolution": "node",
"sourceMap": true,
"suppressImplicitAnyIndexErrors": true,
"skipLibCheck": true,
"outDir": "build/resources/main/META-INF/resourcesapp",
"lib": ["es2017", "dom", "esnext"],
"baseUrl": "./",
"paths": {
"@app/*": ["src/main/webapp/app/*"]
},
updated the webpack.common.js
from this
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const AngularCompilerPlugin = require('@ngtools/webpack').AngularCompilerPlugin;
const utils = require('./utils.js');
module.exports = (options) => ({
extensions: ['.ts', '.js'],
modules: ['node_modules'],
mainFields: ['es2015', 'browser', 'module', 'main'],
alias: utils.mapTypescriptAliasToWebpackAlias()
},
stats: {
children: false
rules: [
{
test: /(?:.ngfactory.js|.ngstyle.js|.ts)$/,
loader: '@ngtools/webpack'
},
{
test: /.html$/,
minifyCSS: false
}
},
exclude: utils.root('src/main/webapp/index.html')
},
{
test: /.(jpe?g|png|gif|svg|woff2?|ttf|eot)$/i,
loader: 'file-loader',
options: {
digest: 'hex',
hash: 'sha512',
// For fixing src attr of image
// See https://github.com/jhipster/generator-jhipster/issues/11209
name: 'content/[hash].[ext]',
esModule: false
}
},
{
test: /manifest.webapp$/,
loader: 'file-loader',
options: {
name: 'manifest.webapp'
}
},
// Ignore warnings about System.import in Angular
{ test: /[/\]@angular[/\].+.js$/, parser: { system: true } },
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: `'${options.env}'`,
BUILD_TIMESTAMP: `'${new Date().getTime()}'`,
// APP_VERSION is passed as an environment variable from the Gradle / Maven build tasks.
VERSION: `'${process.env.hasOwnProperty('APP_VERSION') ? process.env.APP_VERSION : 'DEV'}'`,
DEBUG_INFO_ENABLED: options.env === 'development',
// The root URL for API calls, ending with a '/' - for example: `"https://www.jhipster.tech:8081/myservice/"`.
// If this URL is left empty (""), then it will be relative to the current context.
// If you use an API server, in `prod` mode, you will need to enable CORS
// (see the `jhipster.cors` common JHipster property in the `application-*.yml` configurations)
SERVER_API_URL: `''`
}
}),
new CopyWebpackPlugin({
{ from: './src/main/webapp/content/', to: 'content' },
{ from: './src/main/webapp/favicon.ico', to: 'favicon.ico' },
{ from: './src/main/webapp/manifest.webapp', to: 'manifest.webapp' },
// jhipster-needle-add-assets-to-webpack - JHipster will add/remove third-party resources in this array
{ from: './src/main/webapp/robots.txt', to: 'robots.txt' }
],
}),
inject: 'body',
base: '/',
}),
new AngularCompilerPlugin({
mainPath: utils.root('src/main/webapp/app/app.main.ts'),
tsConfigPath: utils.root('tsconfig.app.json'),
sourceMap: true
})
]
});
to this
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { AngularWebpackPlugin } = require('@ngtools/webpack');
const utils = require('./utils.js');
module.exports = (options) => ({
extensions: ['.ts', '.js'],
modules: [path.join(__dirname, '../node_modules')],
mainFields: ['es2015', 'browser', 'module', 'main'],
alias: {
'@': path.resolve(__dirname, 'src'),
...utils.mapTypescriptAliasToWebpackAlias()
}
},
stats: {
children: false
rules: [
{
test: /(?:.ngfactory.js|.ngstyle.js|.ts)$/,
use: '@ngtools/webpack'
},
{
test: /.html$/,
minifyCSS: false
}
},
exclude: path.resolve(__dirname, 'src/main/webapp/index.html')
},
{
test: /.(jpe?g|png|gif|svg|woff2?|ttf|eot)$/i,
type: 'asset/resource',
generator: {
filename: 'content/[hash][ext][query]'
}
},
{
test: /manifest.webapp$/,
type: 'asset/resource',
generator: {
filename: 'manifest.webapp'
}
},
{ test: /[/\]@angular[/\].+.js$/, parser: { system: true } },
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(options.env),
BUILD_TIMESTAMP: JSON.stringify(new Date().getTime()),
VERSION: JSON.stringify(process.env.APP_VERSION || 'DEV'),
DEBUG_INFO_ENABLED: options.env === 'development',
SERVER_API_URL: JSON.stringify('')
}
}),
new CopyWebpackPlugin({
{ from: './src/main/webapp/content/', to: 'content' },
{ from: './src/main/webapp/favicon.ico', to: 'favicon.ico' },
{ from: './src/main/webapp/manifest.webapp', to: 'manifest.webapp' },
{ from: './src/main/webapp/robots.txt', to: 'robots.txt' }
],
}),
inject: 'body',
base: '/',
}),
new AngularWebpackPlugin({
tsconfig: path.resolve(__dirname, 'tsconfig.app.json'),
sourceMap: true
})
]
});
my webpack.dev.js
const webpack = require('webpack');
const writeFilePlugin = require('write-file-webpack-plugin');
const webpackMerge = require('webpack-merge');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin');
const WebpackNotifierPlugin = require('webpack-notifier');
const path = require('path');
const sass = require('sass');
const utils = require('./utils.js');
const commonConfig = require('./webpack.common.js');
const ENV = 'development';
module.exports = (options) => webpackMerge(commonConfig({ env: ENV }), {
devtool: 'eval-source-map',
devServer: {
contentBase: './build/resources/main/META-INF/resources',
proxy: [{
context: [
'/api',
secure: false,
changeOrigin: options.tls
}],
stats: options.stats,
watchOptions: {
ignored: /node_modules/
},
https: options.tls,
historyApiFallback: true
},
entry: {
global: './src/main/webapp/content/scss/global.scss',
main: './src/main/webapp/app/app.main'
},
output: {
path: utils.root('build/resources/main/META-INF/resources'),
proxy: {
target: `http${options.tls ? 's' : ''}://localhost:9060`,
proxyOptions: {
changeOrigin: false //pass the Host header to the backend unchanged https://github.com/Browsersync/browser-sync/issues/430
}
},
socket: {
heartbeatTimeout: 60000
}
}
/*
,ghostMode: { // uncomment this part to disable BrowserSync ghostMode; https://github.com/jhipster/generator-jhipster/issues/11116
clicks: false,
location: false,
forms: false,
scroll: false
} */
}, {
reload: false
}),
/angular(\|/)core(\|/)/,
path.resolve(__dirname, './src/main/webapp/')
),
new writeFilePlugin(),
new webpack.WatchIgnorePlugin([
utils.root('src/test'),
]),
new WebpackNotifierPlugin({
title: 'JHipster',
contentImage: path.join(__dirname, 'logo-jhipster.png')
})
].filter(Boolean),
mode: 'development'
});
to this
const webpack = require('webpack');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const FriendlyErrorsWebpackPlugin = require('@soda/friendly-errors-webpack-plugin');
const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin');
const WebpackNotifierPlugin = require('webpack-notifier');
const path = require('path');
const sass = require('sass');
const { merge } = require('webpack-merge');
const utils = require('./utils.js');
const commonConfig = require('./webpack.common.js');
const ENV = 'development';
module.exports = (options) => merge(commonConfig({ env: ENV }), {
devtool: 'eval-source-map',
devServer: {
static: './build/resources/main/META-INF/resources',
proxy: [{
context: [
'/api',
secure: false,
changeOrigin: options.tls
}],
devMiddleware: {
stats: options.stats,
},
watchFiles: {
paths: ['src/**/*'],
options: {
ignored: /node_modules/
},
},
https: options.tls,
historyApiFallback: true
},
entry: {
global: path.resolve(__dirname, './src/main/webapp/content/scss/global.scss'),
main: path.resolve(__dirname, './src/main/webapp/app/app.main.ts'),
},
output: {
path: utils.root('build/resources/main/META-INF/resources'),
proxy: {
target: `http${options.tls ? 's' : ''}://localhost:9060`,
proxyOptions: {
changeOrigin: false
}
},
socket: {
heartbeatTimeout: 60000
}
}
}, {
reload: false
}),
/angular(\|/)core(\|/)/,
path.resolve(__dirname, './src/main/webapp/')
),
new WebpackNotifierPlugin({
title: 'JHipster',
contentImage: path.join(__dirname, 'logo-jhipster.png')
})
].filter(Boolean),
mode: 'development'
});
my webpack.prod.js from this
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
const ENV = 'production';
const sass = require('sass');
module.exports = webpackMerge(commonConfig({ env: ENV }), {
// Enable source maps. Please note that this will slow down the build.
// You have to enable it in Terser config below and in tsconfig.json as well
// devtool: 'source-map',
entry: {
global: './src/main/webapp/content/scss/global.scss',
main: './src/main/webapp/app/app.main'
},
output: {
path: utils.root('build/resources/main/META-INF/resources'),
filename: 'app/[name].[hash].bundle.js',
chunkFilename: 'app/[id].[hash].chunk.js'
},
module: {
rules: [
]
}]
},
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: 'content/[name].[contenthash].css',
chunkFilename: 'content/[id].css'
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
// Webpack statistics in target folder
reportFilename: '../stats.html'
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
new WorkboxPlugin.GenerateSW({
clientsClaim: true,
skipWaiting: true,
exclude: [/swagger-ui/]
})
],
mode: 'production'
});
to this
const webpack = require('webpack');
const { merge } = require('webpack-merge');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
const ENV = 'production';
const sass = require('sass');
module.exports = merge(commonConfig({ env: ENV }), {
// Enable source maps. Please note that this will slow down the build.
// You have to enable it in Terser config below and in tsconfig.json as well
// devtool: 'source-map',
entry: {
global: path.resolve(__dirname, './src/main/webapp/content/scss/global.scss'),
main: path.resolve(__dirname, './src/main/webapp/app/app.main.ts'),
},
output: {
path: utils.root('build/resources/main/META-INF/resources'),
filename: 'app/[name].[contenthash].bundle.js',
chunkFilename: 'app/[id].[contenthash].chunk.js'
},
module: {
rules: [
]
}]
},
optimization: {
minimize: true,
minimizer: [
`...`,
new CssMinimizerPlugin()
]
},
plugins: [
new MiniCssExtractPlugin({
filename: 'content/[name].[contenthash].css',
chunkFilename: 'content/[id].css'
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
reportFilename: '../stats.html'
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
new WorkboxPlugin.GenerateSW({
clientsClaim: true,
skipWaiting: true,
exclude: [/swagger-ui/]
})
],
mode: 'production'
});
and it still showing the same issue
Sauri Vega is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.