-
Notifications
You must be signed in to change notification settings - Fork 27
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
String replace plugin fails with Webpack 2.1 (2.1.0-beta.27) #20
Comments
@mlcohen Hi there, I don't know of simple fix off the bat and am unfortunately a bit short on time to investigate just now. If you get to it before I do, a PR would be welcome. |
I came across this tonight and investigated it a little bit. It looks like something about the way loaders are returned has changed (e.g. no more passing back a random id in the query string). So the immediate problem is that if one tacks on The subsequent problem is that as soon as one stops returning the id, one can't find the original options any more when the loader is called. I suspect that webpack2 redid the loader interface and it would be trivial to fix if the new interface was documented/familiar to someone...unfortunately, that isn't me. |
I finally figured it out. After some searching I came across this raised issue: webpack-contrib#275. Turns out that you can't currently use the new module: {
rules: [{
enforce: "pre",
test: /\.js$/,
exclude: /node_modules/,
loader: StringReplacePlugin.replace({
replacements: [{
pattern: /id="@(\w+):([\w\.]+)"/g,
replacement: function (match, p1, p2) {
return `id="${p2}" defaultMessage={${p1}.${p2}.message}`
}
}]
})
}
} I went back over the webpack2 docs and it does indeed show |
On the latest webpack loader: StringReplacePlugin.replace({... and rules: [{
enforce: 'pre',
test: /\.js$/,
use: [{
loader: StringReplacePlugin.replace({... So maybe this issue should be closed |
@RomanGotsiy Excellent. Thanks for the info 👍🏼 |
I'm trying to upgrade my project from webpack 1.3 to webpack 2.1 (currently 2.1.0-beta.27). In my webpack configuration I'm making use of the string replace webpack plugin which works fine with webpack 1.3 but ends up causing a build error using webpack 2.1. Here is an example of what my config currently looks like with the string replace webpack plugin:
And here is the build error that I'm getting:
Any thoughts on how I can address this? Is there a simple fix that can be applied to my webpack config or is this a compatibility issue between the string replace plugin and webpack 2?
Code to reproduce the problem can be found here:
https://gist.github.com/mlcohen/6d338ce0494f5a2e966ef83474b3ab1b
other details
The text was updated successfully, but these errors were encountered: