Use inline file-loader for require.toUrl
Instead of trying to match on the string, because that string could be anything or change in future versions.
This commit is contained in:
@ -27,23 +27,6 @@ module.exports = (env) => {
|
||||
},
|
||||
module: {
|
||||
rules: [{
|
||||
loader: "string-replace-loader",
|
||||
test: /\.(js|ts)$/,
|
||||
options: {
|
||||
multiple: [
|
||||
{
|
||||
search: "require\\.toUrl\\(",
|
||||
replace: "requireToUrl(",
|
||||
flags: "g",
|
||||
},
|
||||
{
|
||||
search: "require\\.__\\$__nodeRequire",
|
||||
replace: "require",
|
||||
flags: "g",
|
||||
},
|
||||
],
|
||||
},
|
||||
}, {
|
||||
// Ignore a bunch of file types we don't have loaders for. Also ignore
|
||||
// test directories, some files with invalid JSON, and files we don't
|
||||
// actually require but throw warnings or errors. This all seems to be a
|
||||
|
@ -16,29 +16,6 @@ module.exports = merge({
|
||||
path: path.join(root, "dist"),
|
||||
filename: "[hash:6].bundle.js",
|
||||
},
|
||||
module: {
|
||||
rules: [{
|
||||
loader: "string-replace-loader",
|
||||
test: /\.(j|t)s/,
|
||||
options: {
|
||||
multiple: [{
|
||||
// These will be handled by file-loader. We need the location because
|
||||
// they are parsed as URIs and will throw errors if not fully formed.
|
||||
search: "require\\.toUrl",
|
||||
replace: "location.protocol + '//' + location.host + '/' + require",
|
||||
flags: "g",
|
||||
}, {
|
||||
search: "require\\.__\\$__nodeRequire",
|
||||
replace: "require",
|
||||
flags: "g",
|
||||
}, {
|
||||
search: "\\.attributes\\[([^\\]]+)\\] = ([^;]+)",
|
||||
replace: ".setAttribute($1, $2)",
|
||||
flags: "g",
|
||||
}],
|
||||
},
|
||||
}],
|
||||
},
|
||||
node: {
|
||||
module: "empty",
|
||||
crypto: "empty",
|
||||
|
Reference in New Issue
Block a user