Skip to content

Incompatible with recordsPath #25

Description

@rowanoulton

Hey, firstly: thank you for the incredibly useful plugin.

I'd like to use it in conjunction with recordsPath and CommonsChunkPlugin in order to achieve long-term caching but am seeing the records file filled with duplicates after each run. I think this is due to the random query ID added here. This creates many references to the same file like so:

/* in records.json */
/* ... */
"node_modules/string-replace-webpack-plugin/loader.js?id=<hash>!path/to/file.js": 1,
/* then, later: */
"node_modules/string-replace-webpack-plugin/loader.js?id=<another-hash>!path/to/file.js": 2,

(a new copy is added to the records file for each subsequent webpack run)

My assumption is that this ID is necessary in order for the plugin to be used multiple times in the same config. In that case, I wonder if the best solution here is to allow consumers of the plugin to pass in an ID directly, eg:

loader: StringReplacePlugin.replace({
        id: 'some-identifier',
	replacements: [
		{
			pattern: /thing/,
			replacement: /* ... some function .. */
		}
	]
})

I'd be happy to submit a PR to do the above, but wanted to check with you to see if it sounds reasonable first. Let me know what you think ✌

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions