Fix webpack memory leak when copying HTML files

(cherry picked from commit 2804a961cb457cc94d3eaa1fe8ee2f71d9d1261c)
This commit is contained in:
Mark McDowall 2021-05-18 23:22:34 -07:00 committed by Qstick
parent bdc7733faf
commit ba1637087e
4 changed files with 976 additions and 556 deletions

View File

@ -1,6 +1,6 @@
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const CopyPlugin = require('copy-webpack-plugin'); const FileManagerPlugin = require('filemanager-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const LiveReloadPlugin = require('webpack-livereload-plugin'); const LiveReloadPlugin = require('webpack-livereload-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
@ -23,7 +23,7 @@ module.exports = (env) => {
const config = { const config = {
mode: isProduction ? 'production' : 'development', mode: isProduction ? 'production' : 'development',
devtool: 'source-map', devtool: isProduction ? 'source-map' : 'eval-source-map',
stats: { stats: {
children: false children: false
@ -87,46 +87,47 @@ module.exports = (env) => {
}), }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: 'frontend/src/index.html', template: 'frontend/src/index.ejs',
filename: 'index.html', filename: 'index.html',
publicPath: '/' publicPath: '/'
}), }),
new CopyPlugin({ new FileManagerPlugin({
patterns: [ events: {
// HTML onEnd: {
{ copy: [
from: 'frontend/src/*.html', // HTML
to: path.join(distFolder, '[name][ext]'), {
globOptions: { source: 'frontend/src/*.html',
ignore: ['**/index.html'] destination: distFolder
} },
},
// Fonts // Fonts
{ {
from: 'frontend/src/Content/Fonts/*.*', source: 'frontend/src/Content/Fonts/*.*',
to: path.join(distFolder, 'Content/Fonts', '[name][ext]') destination: path.join(distFolder, 'Content/Fonts')
}, },
// Icon Images // Icon Images
{ {
from: 'frontend/src/Content/Images/Icons/*.*', source: 'frontend/src/Content/Images/Icons/*.*',
to: path.join(distFolder, 'Content/Images/Icons', '[name][ext]') destination: path.join(distFolder, 'Content/Images/Icons')
}, },
// Images // Images
{ {
from: 'frontend/src/Content/Images/*.*', source: 'frontend/src/Content/Images/*.*',
to: path.join(distFolder, 'Content/Images', '[name][ext]') destination: path.join(distFolder, 'Content/Images')
}, },
// Robots // Robots
{ {
from: 'frontend/src/Content/robots.txt', source: 'frontend/src/Content/robots.txt',
to: path.join(distFolder, 'Content', '[name][ext]') destination: path.join(distFolder, 'Content/robots.txt')
}
]
} }
] }
}), }),
new LiveReloadPlugin() new LiveReloadPlugin()

View File

@ -99,7 +99,6 @@
"babel-loader": "8.2.2", "babel-loader": "8.2.2",
"babel-plugin-inline-classnames": "2.0.1", "babel-plugin-inline-classnames": "2.0.1",
"babel-plugin-transform-react-remove-prop-types": "0.4.24", "babel-plugin-transform-react-remove-prop-types": "0.4.24",
"copy-webpack-plugin": "8.1.1",
"core-js": "3.11.0", "core-js": "3.11.0",
"css-loader": "5.2.4", "css-loader": "5.2.4",
"eslint": "7.25.0", "eslint": "7.25.0",
@ -110,6 +109,7 @@
"eslint-plugin-simple-import-sort": "7.0.0", "eslint-plugin-simple-import-sort": "7.0.0",
"esprint": "2.0.0", "esprint": "2.0.0",
"file-loader": "6.2.0", "file-loader": "6.2.0",
"filemanager-webpack-plugin": "5.0.0",
"html-webpack-plugin": "5.3.1", "html-webpack-plugin": "5.3.1",
"loader-utils": "^2.0.0", "loader-utils": "^2.0.0",
"mini-css-extract-plugin": "1.5.0", "mini-css-extract-plugin": "1.5.0",

1463
yarn.lock

File diff suppressed because it is too large Load Diff