update to webpack 5

This commit is contained in:
Daniel
2020-10-16 14:58:11 -04:00
parent ae25fe8fe2
commit c37f2e1946
5 changed files with 2120 additions and 2514 deletions

View File

@@ -1,54 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Chaotic Backup</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Chaotic Backup">
<link rel="stylesheet" type="text/css" href="/src/css/legacy.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"/>
<style>
html, body, div, span, a, p, ul, li, h1 {
margin: 0;
border: 0;
padding: 0;
}
a {
color: inherit;
text-decoration: inherit;
}
html, body { height: 100%; }
html { background-color:#494949; }
#root { min-height: 100%; }
body { overflow-x: hidden; }
</style>
<!-- Start Single Page Apps for GitHub Pages -->
<script type="text/javascript">
(function(l) {
if (l.search) {
var q = {};
l.search.slice(1).split('&').forEach(function(v) {
var a = v.split('=');
q[a[0]] = a.slice(1).join('=').replace(/~and~/g, '&');
});
if (q.p !== undefined) {
window.history.replaceState(null, null,
l.pathname.slice(0, -1) + (q.p || '') +
(q.q ? ('?' + q.q) : '') +
l.hash
);
}
}
}(window.location))
</script>
<!-- End Single Page Apps for GitHub Pages -->
</head>
<body>
<div id="root"></div>
<script src="/build/main.js"></script>
<script src="/build/vendor.js"></script>
</body>
</html>

4492
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
"version": "2.1.0",
"description": "Chaotic Backup",
"scripts": {
"start": "webpack serve --mode development --env development",
"start": "webpack-cli serve --mode development --env development",
"build": "webpack -p",
"lint": "tsc --noEmit && eslint '*/**/*.{js,ts,tsx}'",
"lint:fix": "tsc --noEmit && eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
@@ -39,23 +39,23 @@
"whatwg-fetch": "^3.4.1"
},
"devDependencies": {
"@babel/cli": "^7.12.0",
"@babel/core": "^7.12.0",
"@babel/node": "^7.10.5",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-proposal-decorators": "^7.10.5",
"@babel/plugin-proposal-dynamic-import": "^7.10.4",
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.1",
"@babel/node": "^7.12.1",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-decorators": "^7.12.1",
"@babel/plugin-proposal-dynamic-import": "^7.12.1",
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-computed-properties": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.12.0",
"@babel/polyfill": "^7.11.5",
"@babel/preset-env": "^7.12.0",
"@babel/preset-react": "^7.10.4",
"@babel/preset-typescript": "^7.12.0",
"@babel/register": "^7.12.0",
"@babel/runtime": "^7.12.0",
"@types/chai": "^4.2.13",
"@babel/plugin-transform-computed-properties": "^7.12.1",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/preset-react": "^7.12.1",
"@babel/preset-typescript": "^7.12.1",
"@babel/register": "^7.12.1",
"@babel/runtime": "^7.12.1",
"@types/chai": "^4.2.14",
"@types/mocha": "^8.0.3",
"@types/react": "^16.9.52",
"@types/react-dom": "^16.9.8",
@@ -66,29 +66,33 @@
"babel-loader": "^8.1.0",
"chai": "^4.2.0",
"cross-env": "^7.0.2",
"css-loader": "^3.6.0",
"css-loader": "^5.0.0",
"css-minimizer-webpack-plugin": "^1.1.5",
"eslint": "^6.8.0",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-react": "^7.21.4",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react-hooks": "^3.0.0",
"eslint-plugin-react": "^7.21.4",
"eslint-plugin-react-hooks": "^4.1.2",
"ignore-styles": "^5.0.1",
"jsdom": "^16.4.0",
"jsdom-global": "^3.0.2",
"mini-css-extract-plugin": "^0.9.0",
"mini-css-extract-plugin": "^1.0.0",
"mocha": "^8.1.3",
"node-sass": "^4.14.1",
"optimize-css-assets-webpack-plugin": "^5.0.4",
"sass-loader": "^8.0.2",
"style-loader": "^1.3.0",
"terser-webpack-plugin": "^2.3.8",
"postcss": "^8.1.0",
"sass-loader": "^10.0.3",
"style-loader": "^2.0.0",
"terser-webpack-plugin": "^5.0.0",
"ts-node": "^9.0.0",
"typescript": "^4.0.3",
"webpack": "^4.44.2",
"webpack": "^5.1.3",
"webpack-cli": "^4.0.0",
"webpack-dev-server": "^3.11.0"
},
"browser": {
"fs": false
},
"browserslist": {
"production": [
">0.2%",

View File

@@ -19,6 +19,7 @@
"strictBindCallApply": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": false,
"suppressImplicitAnyIndexErrors": true,
// Disallow features that require cross-file information for emit.
"isolatedModules": true,
// Import non-ES modules as default imports.
@@ -30,15 +31,17 @@
"resolveJsonModule": true,
// Library files to be used in the project.
// Tells the compiler that "DOM-APIs" and new ECMAScript features are valid.
"lib": ["dom", "ES2019"],
"lib": ["dom", "esnext"],
// Allows @decorators
"experimentalDecorators": true,
// Skips checking libraries
"skipLibCheck": true,
// List of folders to include type definitions from.
"typeRoots": [
"./node_modules/@types"
]
],
// Skips checking libraries
"skipLibCheck": true,
// Emite source map for Babel
"inlineSourceMap": true
},
"include": [
"./src"

View File

@@ -3,7 +3,7 @@ const path = require('path');
const webpack = require('webpack');
const TerserWebpackPlugin = require('terser-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
require('@babel/register');
const devMode = (process.env.NODE_ENV !== 'production' && process.argv.indexOf('-p') === -1);
@@ -11,12 +11,17 @@ const devMode = (process.env.NODE_ENV !== 'production' && process.argv.indexOf('
module.exports = {
entry: ['@babel/polyfill', './src/components/index.js'],
devtool: 'inline-source-map',
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
devServer: {
host: '0.0.0.0',
port: 8000,
publicPath: '/build/',
contentBase: __dirname,
historyApiFallback: {
index: 'index.html',
},
@@ -24,18 +29,16 @@ module.exports = {
output: {
path: path.resolve(__dirname, 'build'),
filename: 'main.js',
filename: '[name].js',
chunkFilename: '[name].js',
publicPath: '/build/',
},
optimization: {
minimize: true,
minimizer: [
// https://www.stackery.io/blog/webpack-upgrade/
new TerserWebpackPlugin({
cache: true,
parallel: true,
sourceMap: true,
extractComments: true,
terserOptions: {
parse: {
@@ -46,7 +49,7 @@ module.exports = {
}
}
}),
new OptimizeCSSAssetsPlugin({}),
new CssMinimizerPlugin()
],
splitChunks: {
cacheGroups: {
@@ -57,7 +60,7 @@ module.exports = {
// sync + async chunks
chunks: 'all',
// import file path containing node_modules
test: /node_modules/,
test: /[\\/]node_modules[\\/]/,
priority: 20,
},
styles: {
@@ -112,10 +115,6 @@ module.exports = {
],
},
node: {
fs: 'empty',
},
// First array is dev only, second is production
plugins: devMode
? [