From 213f1e84c4e56d11d82ba7f8c3e7599e72f3ea8e Mon Sep 17 00:00:00 2001 From: Brugarolas Date: Sat, 18 Sep 2021 04:50:59 +0200 Subject: [PATCH] Fix Webpack 5 build --- package.json | 32 ++++++++++++++++---------------- webpack.config.js | 16 +++++++--------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index 63e80e8..95f7fd3 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { "name": "bruga-weather", - "version": "1.6.0", + "version": "1.7.0", "description": "Simple weather app made with <3 by Andrés Brugarolas", "main": "webpack.config.js", "scripts": { "start": "webpack serve --mode development --hot", "start:local": "webpack serve --mode development --hot --env NODE_ENV=local", "start:static": "npm run build && npm run utils:static-server", - "build": "webpack --mode production --progress --performance", - "build:gh-pages": "webpack --mode production --progress --performance --env PUBLIC_PATH=bruga-weather", - "build:analyzer": "webpack --mode production --progress --performance --analyze", + "build": "webpack --mode production --progress", + "build:gh-pages": "webpack --mode production --progress --env PUBLIC_PATH=bruga-weather", + "build:analyzer": "webpack --mode production --progress --analyze", "icons:add": "node scripts/download-icon", "icons:update-included": "node scripts/download-included-icons", "utils:static-server": "http-server ./dist --cors", @@ -24,16 +24,16 @@ "license": "MIT", "private": true, "dependencies": { - "@babel/runtime-corejs3": "^7.15.3", + "@babel/runtime-corejs3": "^7.15.4", "@brugarolas/swing": "^3.3.0", "clsx": "^1.1.1", - "core-js": "^3.16.4", - "immer": "^9.0.5", + "core-js": "^3.17.3", + "immer": "^9.0.6", "puppeteer": "^10.2.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-flip-move": "^3.0.4", - "react-redux": "^7.2.4", + "react-redux": "^7.2.5", "redux": "^4.1.1", "reselect": "^4.0.0", "sister": "^3.0.2", @@ -41,10 +41,10 @@ "yaku": "^1.0.1" }, "devDependencies": { - "@babel/core": "^7.15.0", + "@babel/core": "^7.15.5", "@babel/plugin-proposal-class-properties": "^7.14.5", "@babel/plugin-transform-runtime": "^7.15.0", - "@babel/preset-env": "^7.15.0", + "@babel/preset-env": "^7.15.6", "@babel/preset-react": "^7.14.5", "@supercharge/promise-pool": "^1.7.0", "babel-loader": "^8.2.2", @@ -55,17 +55,17 @@ "file-loader": "^6.2.0", "html-loader": "^2.1.2", "html-webpack-plugin": "^5.3.2", - "http-server": "^13.0.1", + "http-server": "^13.0.2", "less": "^4.1.1", "less-loader": "^10.0.1", - "mini-css-extract-plugin": "^2.2.1", - "npm-check-updates": "^11.8.3", - "svgo": "^2.5.0", + "mini-css-extract-plugin": "^2.3.0", + "npm-check-updates": "^11.8.5", + "svgo": "^2.6.1", "webfonts-loader": "^7.3.0", - "webpack": "^5.51.1", + "webpack": "^5.53.0", "webpack-bundle-analyzer": "^4.4.2", "webpack-cli": "^4.8.0", - "webpack-dev-server": "^4.0.0" + "webpack-dev-server": "^4.2.1" }, "resolutions": { "semver": "^7.3.2" diff --git a/webpack.config.js b/webpack.config.js index f28cf60..c04a10d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,7 +2,7 @@ const path = require('path'); const webpack = require('webpack'); const HtmlWebPackPlugin = require('html-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const FaviconsWebpackPlugin = require('favicons-webpack-plugin'); +// const FaviconsWebpackPlugin = require('favicons-webpack-plugin'); const DefinePlugin = webpack.DefinePlugin; module.exports = (env, args) => { @@ -124,13 +124,14 @@ module.exports = (env, args) => { new HtmlWebPackPlugin({ template: './src/index.html', filename: './index.html', + favicon: './src/assets/logo.png', // Delete when Favicon plugin is supported again meta: { viewport: 'user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no', description: 'Simple weather app made with <3 by Andrés Brugarolas' }, inject: true - }), - new FaviconsWebpackPlugin('./src/assets/logo.png') + }) + // new FaviconsWebpackPlugin('./src/assets/logo.png') // Webpack 5 still not supported ], resolve: { alias: { @@ -154,16 +155,13 @@ module.exports = (env, args) => { devtool: 'eval-source-map' }; - if (!isProduction) { - module.exports.devtool = 'eval-source-map'; - } - if (isProduction) { + config.mode = 'production'; + config.devtool = false; + // Add babel-minify preset only in production const babelRules = config.module.rules.find(rule => rule.loader === 'babel-loader'); babelRules.options.presets.unshift(['minify', { builtIns: true } ]); - - module.exports.mode = 'production'; } if (isAnalyzer) {