const webpack = require('webpack'); const webpackMerge = require('webpack-merge'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const WorkboxPlugin = require('workbox-webpack-plugin'); const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); const MomentLocalesPlugin = require('moment-locales-webpack-plugin'); const path = require('path'); const utils = require('./utils.js'); const commonConfig = require('./webpack.common.js'); const ENV = 'production'; module.exports = webpackMerge(commonConfig({ env: ENV }), { // devtool: 'source-map', // Enable source maps. Please note that this will slow down the build mode: ENV, entry: { main: './src/main/webapp/app/index' }, output: { path: utils.root('build/www'), filename: 'app/[name].[hash].bundle.js', chunkFilename: 'app/[name].[hash].chunk.js' }, module: { rules: [ { enforce: 'pre', test: /\.s?css$/, loader: 'stripcomment-loader' }, { test: /\.(sa|sc|c)ss$/, use: [ { loader: MiniCssExtractPlugin.loader, options: { publicPath: '../' } }, 'css-loader', 'postcss-loader', 'sass-loader' ] }, ] }, optimization: { runtimeChunk: false, minimizer: [ new UglifyJsPlugin({ cache: true, parallel: true, // sourceMap: true, // Enable source maps. Please note that this will slow down the build uglifyOptions: { beautify: false, comments: false, compress: { warnings: false }, mangle: { keep_fnames: true } } }), new OptimizeCSSAssetsPlugin({}) ] }, plugins: [ new MiniCssExtractPlugin({ // Options similar to the same options in webpackOptions.output filename: 'content/[name].[hash].css', chunkFilename: 'content/[name].[hash].css' }), new MomentLocalesPlugin({ localesToKeep: [ // jhipster-needle-i18n-language-moment-webpack - JHipster will add/remove languages in this array ] }), new webpack.LoaderOptionsPlugin({ minimize: true, debug: false }), new WorkboxPlugin.GenerateSW({ clientsClaim: true, skipWaiting: true, }) ] });