Archived
1
0

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:
Asher
2019-02-04 14:03:59 -06:00
committed by Kyle Carberry
parent 55f9c81516
commit c80b2fabc3
3 changed files with 28 additions and 49 deletions

View File

@ -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",