Skip to content

Commit df4141b

Browse files
committed
upgrade to webpack 5
1 parent a203b0d commit df4141b

File tree

7 files changed

+9908
-4046
lines changed

7 files changed

+9908
-4046
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Youtube Preview Link: [https://youtu.be/BcpD38IjY6A](https://youtu.be/BcpD38IjY6
7373

7474
Built with the following template:
7575

76-
👉 👉 [Chrome Extension Boilerplate with React 16.6+ and Webpack 4+](https://github.com/lxieyang/chrome-extension-boilerplate-react)
76+
👉 👉 [Chrome Extension Boilerplate with React 17 and Webpack 5](https://github.com/lxieyang/chrome-extension-boilerplate-react)
7777

7878
---
7979

package-lock.json

Lines changed: 9809 additions & 3977 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vertical-tabs-chrome-extension",
3-
"version": "1.8.0",
3+
"version": "1.9.0",
44
"description": "A chrome extension that presents your tabs vertically.",
55
"license": "MIT",
66
"repository": {
@@ -14,61 +14,64 @@
1414
},
1515
"dependencies": {
1616
"@hot-loader/react-dom": "^16.12.0",
17-
"@material-ui/core": "^4.9.8",
18-
"@material-ui/lab": "^4.0.0-alpha.47",
17+
"@material-ui/core": "^4.11.0",
18+
"@material-ui/lab": "^4.0.0-alpha.56",
19+
"@types/chrome": "0.0.125",
1920
"classnames": "^2.2.6",
2021
"clipboard-copy": "^3.1.0",
2122
"glamor": "^2.20.40",
22-
"immutability-helper": "^3.0.1",
23-
"jquery": "^3.4.1",
24-
"lodash": "^4.17.15",
23+
"immutability-helper": "^3.1.1",
24+
"jquery": "^3.5.1",
25+
"lodash": "^4.17.20",
2526
"prop-types": "^15.7.2",
26-
"re-resizable": "^6.1.1",
27+
"re-resizable": "^6.7.0",
2728
"react": "^16.12.0",
28-
"react-contextmenu": "^2.13.0",
29-
"react-dnd": "^9.5.1",
30-
"react-dnd-html5-backend": "^9.5.1",
29+
"react-contextmenu": "^2.14.0",
30+
"react-dnd": "^11.1.3",
31+
"react-dnd-html5-backend": "^11.1.3",
3132
"react-dom": "^16.12.0",
32-
"react-hot-loader": "^4.12.20",
33+
"react-hot-loader": "^4.13.0",
3334
"react-hover-observer": "^2.1.1",
34-
"react-icons": "^3.9.0",
35-
"react-loader-spinner": "^3.1.5",
35+
"react-icons": "^3.11.0",
36+
"react-loader-spinner": "^3.1.14",
3637
"react-media": "^1.10.0",
3738
"react-tiny-popover": "^4.0.0",
3839
"styled-components": "^4.4.1"
3940
},
4041
"devDependencies": {
41-
"@babel/core": "^7.5.5",
42-
"@babel/plugin-proposal-class-properties": "^7.5.5",
43-
"@babel/preset-env": "^7.5.5",
44-
"@babel/preset-react": "^7.0.0",
45-
"babel-eslint": "^10.0.2",
46-
"babel-loader": "^8.0.6",
47-
"babel-preset-react-app": "^9.0.0",
42+
"@babel/core": "^7.12.3",
43+
"@babel/plugin-proposal-class-properties": "^7.12.1",
44+
"@babel/preset-env": "^7.12.1",
45+
"@babel/preset-react": "^7.12.1",
46+
"babel-eslint": "^10.1.0",
47+
"babel-loader": "^8.1.0",
48+
"babel-preset-react-app": "^10.0.0",
4849
"clean-webpack-plugin": "^3.0.0",
49-
"copy-webpack-plugin": "^5.0.5",
50-
"css-loader": "^3.2.0",
51-
"eslint": "^6.2.2",
52-
"eslint-config-prettier": "^6.1.0",
53-
"eslint-config-react-app": "^5.0.1",
54-
"eslint-plugin-flowtype": "^4.2.0",
55-
"eslint-plugin-import": "^2.18.2",
56-
"eslint-plugin-jsx-a11y": "^6.2.3",
57-
"eslint-plugin-react": "^7.14.3",
58-
"eslint-plugin-react-hooks": "^2.0.1",
59-
"file-loader": "^4.2.0",
60-
"fs-extra": "^8.1.0",
61-
"html-loader": "0.5.5",
62-
"html-webpack-plugin": "3.2.0",
63-
"husky": "^3.0.4",
64-
"lint-staged": "^9.2.0",
65-
"prettier": "1.18.2",
50+
"copy-webpack-plugin": "^6.2.1",
51+
"css-loader": "^5.0.0",
52+
"eslint": "^7.12.1",
53+
"eslint-config-prettier": "^6.14.0",
54+
"eslint-config-react-app": "^6.0.0",
55+
"eslint-plugin-flowtype": "^5.2.0",
56+
"eslint-plugin-import": "^2.22.1",
57+
"eslint-plugin-jsx-a11y": "^6.4.1",
58+
"eslint-plugin-react": "^7.21.5",
59+
"eslint-plugin-react-hooks": "^4.2.0",
60+
"file-loader": "^6.1.1",
61+
"fs-extra": "^9.0.1",
62+
"html-loader": "^1.3.2",
63+
"html-webpack-plugin": "^5.0.0-alpha.7",
64+
"husky": "^4.3.0",
65+
"lint-staged": "^10.5.0",
66+
"node-sass": "^4.14.1",
67+
"prettier": "^2.1.2",
6668
"pretty-quick": "^1.11.1",
67-
"style-loader": "^1.0.0",
68-
"webpack": "^4.42.1",
69-
"webpack-cli": "^3.3.11",
70-
"webpack-dev-server": "3.2.1",
71-
"write-file-webpack-plugin": "^4.5.1"
69+
"sass-loader": "^10.0.4",
70+
"style-loader": "^2.0.0",
71+
"terser-webpack-plugin": "^5.0.2",
72+
"webpack": "^5.3.0",
73+
"webpack-cli": "^4.1.0",
74+
"webpack-dev-server": "^3.11.0"
7275
},
7376
"husky": {
7477
"hooks": {

src/components/Logo/Logo.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const logo = (props) => {
1313
let src = AppLogo;
1414

1515
if (window.chrome !== undefined && chrome.extension !== undefined) {
16-
src = chrome.extension.getURL(AppLogo);
16+
src = chrome.extension.getURL('icon-128.png');
1717
}
1818

1919
return (

src/pages/Sidebar/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, useEffect } from 'react';
22
import { render } from 'react-dom';
33
import { DndProvider } from 'react-dnd';
4-
import HTML5Backend from 'react-dnd-html5-backend';
4+
import { HTML5Backend } from 'react-dnd-html5-backend';
55
import Media from 'react-media';
66

77
import Sidebar from './Sidebar';

utils/webserver.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ delete config.chromeExtensionBoilerplate;
2929
var compiler = webpack(config);
3030

3131
var server = new WebpackDevServer(compiler, {
32+
https: false,
3233
hot: true,
34+
injectClient: false,
35+
writeToDisk: true,
36+
port: env.PORT,
3337
contentBase: path.join(__dirname, '../build'),
34-
// sockPort: env.PORT,
38+
publicPath: `http://localhost:${env.PORT}`,
3539
headers: {
3640
'Access-Control-Allow-Origin': '*',
3741
},

webpack.config.js

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var webpack = require('webpack'),
55
{ CleanWebpackPlugin } = require('clean-webpack-plugin'),
66
CopyWebpackPlugin = require('copy-webpack-plugin'),
77
HtmlWebpackPlugin = require('html-webpack-plugin'),
8-
WriteFilePlugin = require('write-file-webpack-plugin');
8+
TerserPlugin = require('terser-webpack-plugin');
99

1010
// load the secrets
1111
var alias = {
@@ -49,13 +49,30 @@ var options = {
4949
module: {
5050
rules: [
5151
{
52-
test: /\.css$/,
53-
loader: 'style-loader!css-loader',
54-
exclude: /node_modules/,
52+
// look for .css or .scss files
53+
test: /\.(css|scss)$/,
54+
// in the `src` directory
55+
use: [
56+
{
57+
loader: 'style-loader',
58+
},
59+
{
60+
loader: 'css-loader',
61+
},
62+
{
63+
loader: 'sass-loader',
64+
options: {
65+
sourceMap: true,
66+
},
67+
},
68+
],
5569
},
5670
{
5771
test: new RegExp('.(' + fileExtensions.join('|') + ')$'),
58-
loader: 'file-loader?name=[name].[ext]',
72+
loader: 'file-loader',
73+
options: {
74+
name: '[name].[ext]',
75+
},
5976
exclude: /node_modules/,
6077
},
6178
{
@@ -74,7 +91,7 @@ var options = {
7491
alias: alias,
7592
extensions: fileExtensions
7693
.map((extension) => '.' + extension)
77-
.concat(['.jsx', '.js', '.css']),
94+
.concat(['.js', '.jsx', '.css']),
7895
},
7996
plugins: [
8097
new webpack.ProgressPlugin(),
@@ -85,13 +102,13 @@ var options = {
85102
}),
86103
// expose and write the allowed env vars on the compiled bundle
87104
new webpack.EnvironmentPlugin(['NODE_ENV']),
88-
new CopyWebpackPlugin(
89-
[
105+
new CopyWebpackPlugin({
106+
patterns: [
90107
{
91108
from: 'src/manifest.json',
92109
to: path.join(__dirname, 'build'),
93110
force: true,
94-
transform: function(content, path) {
111+
transform: function (content, path) {
95112
// generates the manifest file using the package.json informations
96113
return Buffer.from(
97114
JSON.stringify({
@@ -103,33 +120,27 @@ var options = {
103120
},
104121
},
105122
],
106-
{
107-
logLevel: 'info',
108-
copyUnmodified: true,
109-
}
110-
),
111-
new CopyWebpackPlugin(
112-
[
123+
}),
124+
new CopyWebpackPlugin({
125+
patterns: [
113126
{
114127
from: 'src/pages/Content/content.styles.css',
115128
to: path.join(__dirname, 'build'),
116129
force: true,
117130
},
118131
],
119-
{
120-
logLevel: 'info',
121-
copyUnmodified: true,
122-
}
123-
),
132+
}),
124133
new HtmlWebpackPlugin({
125134
template: path.join(__dirname, 'src', 'pages', 'Options', 'index.html'),
126135
filename: 'options.html',
127136
chunks: ['options'],
137+
cache: false,
128138
}),
129139
new HtmlWebpackPlugin({
130140
template: path.join(__dirname, 'src', 'pages', 'Sidebar', 'index.html'),
131141
filename: 'sidebar.html',
132142
chunks: ['sidebar'],
143+
cache: false,
133144
}),
134145
new HtmlWebpackPlugin({
135146
template: path.join(
@@ -141,13 +152,25 @@ var options = {
141152
),
142153
filename: 'background.html',
143154
chunks: ['background'],
155+
cache: false,
144156
}),
145-
new WriteFilePlugin(),
146157
],
158+
infrastructureLogging: {
159+
level: 'info',
160+
},
147161
};
148162

149163
if (env.NODE_ENV === 'development') {
150-
options.devtool = 'cheap-module-eval-source-map';
164+
options.devtool = 'eval-cheap-module-source-map';
165+
} else {
166+
options.optimization = {
167+
minimize: true,
168+
minimizer: [
169+
new TerserPlugin({
170+
extractComments: false,
171+
}),
172+
],
173+
};
151174
}
152175

153176
module.exports = options;

0 commit comments

Comments
 (0)