Skip to content

Commit

Permalink
Fix Webpack 5 build
Browse files Browse the repository at this point in the history
  • Loading branch information
Brugarolas committed Sep 18, 2021
1 parent 3f3fcac commit 213f1e8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -24,27 +24,27 @@
"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",
"unfetch": "^4.2.0",
"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",
Expand All @@ -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"
Expand Down
16 changes: 7 additions & 9 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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: {
Expand All @@ -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) {
Expand Down

0 comments on commit 213f1e8

Please sign in to comment.