-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#113: Upgrade to Webpack 5 #421
Changes from all commits
819165c
bb5871e
2a9a22c
d58b7ff
3afd3c9
253e863
d63b74d
3162af4
1391468
705c038
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ const path = require("path"); | |
const webpack = require("webpack"); | ||
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | ||
const WebExtensionTarget = require("webpack-target-webextension"); | ||
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin"); | ||
|
||
const rootDir = path.resolve(__dirname, "../../"); | ||
|
||
|
@@ -50,20 +51,14 @@ const babelLoader = { | |
|
||
const nodeConfig = { | ||
global: true, | ||
process: true, | ||
Buffer: true, | ||
console: true, | ||
fs: "empty", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Webpack 5 no longer includes polyfills by default, so I ended up using https://github.com/Richienb/node-polyfill-webpack-plugin instead of installing 7 dependencies separately and configuring them here. |
||
}; | ||
|
||
module.exports = { | ||
context: rootDir, | ||
node: nodeConfig, | ||
target: WebExtensionTarget(nodeConfig), | ||
output: { | ||
// https://github.com/crimx/webpack-target-webextension#usage | ||
globalObject: "window", | ||
filename: "[name].js", | ||
chunkFilename: "bundles/[name].bundle.js", | ||
}, | ||
entry: { | ||
|
@@ -93,14 +88,33 @@ module.exports = { | |
rootDir, | ||
"src/contrib/uipath/quietLogger" | ||
), | ||
|
||
// An existence check triggers webpack’s warnings https://github.com/handlebars-lang/handlebars.js/issues/953 | ||
handlebars: "handlebars/dist/handlebars.js", | ||
}, | ||
fallback: { | ||
fs: false, | ||
}, | ||
extensions: [".ts", ".tsx", ".jsx", ".js"], | ||
}, | ||
|
||
// https://github.com/webpack/webpack/issues/3017#issuecomment-285954512 | ||
// prevent lodash from overriding window._ | ||
amd: false, | ||
|
||
optimization: { | ||
// Chrome bug https://bugs.chromium.org/p/chromium/issues/detail?id=1108199 | ||
splitChunks: { automaticNameDelimiter: "-" }, | ||
}, | ||
|
||
// Silence new size limit warnings https://github.com/webpack/webpack/issues/3486#issuecomment-646997697 | ||
performance: { | ||
maxEntrypointSize: 5120000, | ||
maxAssetSize: 5120000, | ||
}, | ||
plugins: [ | ||
new NodePolyfillPlugin(), | ||
new WebExtensionTarget(nodeConfig), | ||
// https://webpack.js.org/plugins/provide-plugin/ | ||
new webpack.ProvidePlugin({ | ||
$: "jquery", | ||
|
@@ -120,29 +134,15 @@ module.exports = { | |
}, | ||
}), | ||
new MiniCssExtractPlugin({ | ||
filename: "[name].css", | ||
chunkFilename: "bundles/[name].bundle.css", | ||
chunkFilename: "css/[id].css", | ||
}), | ||
], | ||
module: { | ||
rules: [ | ||
// https://github.com/webpack/webpack/issues/3017#issuecomment-285954512 | ||
// prevent lodash from overriding window._ | ||
{ | ||
exclude: /(notifyjs-browser|vendors\/notify)/, | ||
parser: { amd: false }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fregante What was the reason for removing this? I had originally added this since having lodash overwrite window._ breaks sites running older versions of lodash There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I blindly removed this line since it was deprecated:
I pushed a tentative solution for this. It compiles but I haven't run it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I can help show you how to test it. I think you just find a page where the PixieBrix contentScript is loaded and see if it set To do that, you could just click the PixieBrix extension icon in the Chrome toolbar on any page to trigger the browser action, which will inject the contentScript and the side bar There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I also verified that without However I think that this is breaking |
||
}, | ||
{ | ||
test: /\.s?css$/, | ||
use: [ | ||
{ | ||
loader: MiniCssExtractPlugin.loader, | ||
options: { | ||
// you can specify a publicPath here | ||
// by default it uses publicPath in webpackOptions.output | ||
publicPath: "../", | ||
}, | ||
}, | ||
MiniCssExtractPlugin.loader, | ||
"css-loader", | ||
{ loader: "sass-loader", options: { sourceMap: true } }, | ||
], | ||
|
@@ -163,15 +163,10 @@ module.exports = { | |
{ | ||
test: /\.(svg|png|jpg|gif)?$/, | ||
exclude: /(bootstrap-icons|simple-icons|custom-icons)/, | ||
use: [ | ||
{ | ||
loader: "file-loader", | ||
options: { | ||
emitFile: true, | ||
outputPath: "img", | ||
}, | ||
}, | ||
], | ||
type: "asset/resource", | ||
generator: { | ||
filename: "img/[name][ext]", | ||
}, | ||
}, | ||
{ | ||
test: /(bootstrap-icons|simple-icons|custom-icons).*\.svg$/, | ||
|
@@ -180,16 +175,10 @@ module.exports = { | |
{ | ||
test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/, | ||
exclude: /(bootstrap-icons|simple-icons)/, | ||
use: [ | ||
{ | ||
loader: "file-loader", | ||
options: { | ||
name: "[name].[ext]", | ||
outputPath: "fonts/", | ||
publicPath: "fonts/", | ||
}, | ||
}, | ||
], | ||
type: "asset/resource", | ||
generator: { | ||
filename: "fonts/[name][ext]", | ||
}, | ||
}, | ||
{ | ||
test: /\.ya?ml$/, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should already be inherited from
webpack.base.js