From 5247a7f19c3a350c7087db1c7af80c7f37da4599 Mon Sep 17 00:00:00 2001 From: lxieyang Date: Tue, 27 Oct 2020 14:05:17 -0400 Subject: [PATCH] bug fix --- package-lock.json | 142 ++++++++++++---------------------------------- package.json | 8 +-- webpack.config.js | 28 +++++---- 3 files changed, 55 insertions(+), 123 deletions(-) diff --git a/package-lock.json b/package-lock.json index dafc44119..c7de0093a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "chrome-extension-boilerplate-react", - "version": "3.0.0", + "version": "3.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -7110,12 +7110,6 @@ "dev": true, "optional": true }, - "filesize": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/filesize/-/filesize-3.6.1.tgz", - "integrity": "sha512-7KjR1vv6qnicaPMi1iiTcI85CyYwRO/PSFCu6SvqL8jN2Wjt/NIYQTFtFs7fSDCYOstUkEWIQGFUg5YZQfjlcg==", - "dev": true - }, "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", @@ -8355,20 +8349,40 @@ } }, "html-webpack-plugin": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-4.5.0.tgz", - "integrity": "sha512-MouoXEYSjTzCrjIxWwg8gxL5fE2X2WZJLmBYXlaJhQUH5K/b5OrqmV7T4dB7iu0xkmJ6JlUuV6fFVtnqbPopZw==", + "version": "5.0.0-alpha.7", + "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-5.0.0-alpha.7.tgz", + "integrity": "sha512-3sdfEqSjuJ41YpIzweFkTDepTVIuIflvfOh8MhACNk92gE2MsOXL/7MYTVvIHEAeXp+9yTx0DTkYlInCUmtP/g==", "dev": true, "requires": { "@types/html-minifier-terser": "^5.0.0", "@types/tapable": "^1.0.5", - "@types/webpack": "^4.41.8", "html-minifier-terser": "^5.0.1", - "loader-utils": "^1.2.3", - "lodash": "^4.17.15", + "loader-utils": "2.0.0", + "lodash": "^4.17.20", "pretty-error": "^2.1.1", - "tapable": "^1.1.3", - "util.promisify": "1.0.0" + "tapable": "2.0.0" + }, + "dependencies": { + "json5": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz", + "integrity": "sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, + "loader-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", + "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", + "dev": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + } } }, "htmlparser2": { @@ -9582,12 +9596,6 @@ "minimist": "^1.2.5" } }, - "moment": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", - "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==", - "dev": true - }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -10024,16 +10032,6 @@ "has": "^1.0.3" } }, - "object.getownpropertydescriptors": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.0.tgz", - "integrity": "sha512-Z53Oah9A3TdLoblT7VKJaTDdXdT+lQO+cNpKVnya5JDe9uLvzu1YyY1yFDFrcxrlRgWrEFH0jJtD/IbuwjcEVg==", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.0-next.1" - } - }, "object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", @@ -10477,14 +10475,6 @@ "requires": { "lodash": "^4.17.20", "renderkid": "^2.0.4" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - } } }, "process": { @@ -10937,12 +10927,6 @@ "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true }, - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", @@ -12236,9 +12220,9 @@ } }, "tapable": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", - "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.0.0.tgz", + "integrity": "sha512-bjzn0C0RWoffnNdTzNi7rNDhs1Zlwk2tRXgk8EiHKAOX1Mag3d6T0Y5zNa7l9CJ+EoUne/0UHdwS8tMbkh9zDg==", "dev": true }, "tar": { @@ -12278,9 +12262,9 @@ } }, "terser-webpack-plugin": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.0.1.tgz", - "integrity": "sha512-EwUe+XDTFf/2cAlmAlZZ7vRpNKMZUAypX2kIRm0Fmjlz4l7SqbI/VabmgiesNZW2nq/LR0N7ku/wlTQ6ygen0w==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.0.2.tgz", + "integrity": "sha512-adg+JLykDi9HkouHqmVg+qbSGyKSJXioNQl7v79xqyaFbv6a/pCd5nVj4HcTDaFNxt6CzDuUrMEnAEbKA/w/QQ==", "dev": true, "requires": { "jest-worker": "^26.6.1", @@ -12335,15 +12319,6 @@ "ajv-keywords": "^3.5.2" } }, - "serialize-javascript": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-5.0.1.tgz", - "integrity": "sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA==", - "dev": true, - "requires": { - "randombytes": "^2.1.0" - } - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -12703,16 +12678,6 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, - "util.promisify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.0.tgz", - "integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==", - "dev": true, - "requires": { - "define-properties": "^1.1.2", - "object.getownpropertydescriptors": "^2.0.3" - } - }, "utila": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/utila/-/utila-0.4.0.tgz", @@ -13410,43 +13375,6 @@ "mkdirp": "^0.5.1" } }, - "write-file-atomic": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.3.tgz", - "integrity": "sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.11", - "imurmurhash": "^0.1.4", - "signal-exit": "^3.0.2" - } - }, - "write-file-webpack-plugin": { - "version": "4.5.1", - "resolved": "https://registry.npmjs.org/write-file-webpack-plugin/-/write-file-webpack-plugin-4.5.1.tgz", - "integrity": "sha512-AZ7qJUvhTCBiOtG21aFJUcNuLVo2FFM6JMGKvaUGAH+QDqQAp2iG0nq3GcuXmJOFQR2JjpjhyYkyPrbFKhdjNQ==", - "dev": true, - "requires": { - "chalk": "^2.4.0", - "debug": "^3.1.0", - "filesize": "^3.6.1", - "lodash": "^4.17.13", - "mkdirp": "^0.5.1", - "moment": "^2.22.1", - "write-file-atomic": "^2.3.0" - }, - "dependencies": { - "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - } - } - }, "ws": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", diff --git a/package.json b/package.json index 96e279f0c..8722d6457 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chrome-extension-boilerplate-react", - "version": "3.0.0", + "version": "3.0.1", "description": "A chrome extension boilerplate built with React 17 and Webpack 4", "license": "MIT", "repository": { @@ -41,14 +41,14 @@ "file-loader": "^6.1.1", "fs-extra": "^9.0.1", "html-loader": "^1.3.2", - "html-webpack-plugin": "^4.5.0", + "html-webpack-plugin": "^5.0.0-alpha.7", "node-sass": "^4.14.1", "prettier": "^2.1.2", "sass-loader": "^10.0.4", "style-loader": "^2.0.0", + "terser-webpack-plugin": "^5.0.2", "webpack": "^5.2.0", "webpack-cli": "^4.1.0", - "webpack-dev-server": "^3.11.0", - "write-file-webpack-plugin": "^4.5.1" + "webpack-dev-server": "^3.11.0" } } diff --git a/webpack.config.js b/webpack.config.js index 3fc1af415..594b1e831 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -4,13 +4,14 @@ var webpack = require('webpack'), env = require('./utils/env'), { CleanWebpackPlugin } = require('clean-webpack-plugin'), CopyWebpackPlugin = require('copy-webpack-plugin'), - HtmlWebpackPlugin = require('html-webpack-plugin'); + HtmlWebpackPlugin = require('html-webpack-plugin'), + TerserPlugin = require('terser-webpack-plugin'); -// load the secrets var alias = { 'react-dom': '@hot-loader/react-dom', }; +// load the secrets var secretsPath = path.join(__dirname, 'secrets.' + env.NODE_ENV + '.js'); var fileExtensions = [ @@ -48,16 +49,6 @@ var options = { }, module: { rules: [ - // { - // test: /\.css$/, - // loader: 'style-loader!css-loader', - // exclude: /node_modules/, - // }, - // { - // test: /\.scss$/, - // loader: 'sass-loader', - // exclude: /node_modules/, - // }, { // look for .css or .scss files test: /\.(css|scss)$/, @@ -144,16 +135,19 @@ var options = { template: path.join(__dirname, 'src', 'pages', 'Newtab', 'index.html'), filename: 'newtab.html', chunks: ['newtab'], + cache: false, }), new HtmlWebpackPlugin({ template: path.join(__dirname, 'src', 'pages', 'Options', 'index.html'), filename: 'options.html', chunks: ['options'], + cache: false, }), new HtmlWebpackPlugin({ template: path.join(__dirname, 'src', 'pages', 'Popup', 'index.html'), filename: 'popup.html', chunks: ['popup'], + cache: false, }), new HtmlWebpackPlugin({ template: path.join( @@ -165,6 +159,7 @@ var options = { ), filename: 'background.html', chunks: ['background'], + cache: false, }), ], infrastructureLogging: { @@ -174,6 +169,15 @@ var options = { if (env.NODE_ENV === 'development') { options.devtool = 'eval-cheap-module-source-map'; +} else { + options.optimization = { + minimize: true, + minimizer: [ + new TerserPlugin({ + extractComments: false, + }), + ], + }; } module.exports = options;