-
Notifications
You must be signed in to change notification settings - Fork 31
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
Wildcard not matched, instead simply outputted in template #19
Comments
The last time I looked into this, the issue was because the This makes it impossible to do anything other than look at the source files to do minimatching. At the time I last looked into this, development on the Here are some issues that are related: |
Understood. |
Well, combination with If I change // ----------------
// FileManagerPlugin
config.plugins.push(new FileManagerPlugin({
onStart: {
copy: [
{
source: 'src/preflight.js',
destination: 'public/assets/preflight.123.js'
}
],
move: [],
delete: [],
mkdir: []
},
onEnd: {}
})); I can observe that file emitting really differs, However compiled HTML still contains not resolved minimatch against preflight.123.js (contains raw string as specified in HtmlWebpackIncludeAssetsPlugin <script type="text/javascript" src="//webpacktest-codesplitting.test/assets/preflight.*.js"> |
If I strip this aspect of before/after
by
HtmlWebpackIncludeAssetsPlugin still does not find And if I place files
and do either of the following absolute matching approaches config.plugins.push(new HtmlWebpackIncludeAssetsPlugin({
assets: [
`${path.join(__dirname, 'src')}/preflight.*.js`,
`${path.join(__dirname, 'public/assets')}/preflight.*.js`
],
append: false,
hash: false
})); HTML output is still in line with appending raw string that was specified in assets key <script type="text/javascript" src="//webpacktest-codesplitting.test/assets//Users/myuser/path/to/webpacktest-codesplitting/src/preflight.*.js"></script><script type="text/javascript" src="//webpacktest-codesplitting.test/assets//Users/myuser/path/to/webpacktest-codesplitting/public/assets/preflight.*.js"></script> Am I doing something wrong or is this broken (considering that there is no copying involved, files exist in filesystem). |
Sorry, it's a bit hard for me to follow your examples. Do you think you could create a reproduction of the problem so I can take a quick look? |
Hi, I revisited this issue - my bad. Thus to make it work I use FileManagerPlugin to copy files to webpack's output path. It does it And instead of trying to match those files in output path using config.plugins.push(new HtmlWebpackIncludeAssetsPlugin({
assets: [
'preflight.*.js',
'preflight.*.css'
]
})); the way I did in original post #19 (comment) and later comment #19 (comment) config.plugins.push(new HtmlWebpackIncludeAssetsPlugin({
assets: [
{
path: '',
glob: 'preflight.*.js',
globPath: outputPath
},
{
path: '',
glob: 'preflight.*.css',
globPath: outputPath
}
]
}));
It works. And FYI. I can use it only for case where
The other need
will not work. by having config.plugins.push(new ScriptExtHtmlWebpackPlugin({
inline: [
/preflight.*.js$/
]
})); it will throw It knows that the file is called There is ticket for ScriptExtHtmlWebpackPlugin numical/script-ext-html-webpack-plugin#13.
My current sollution if I want to
is to have custom keys in config.plugins.push(new HtmlWebpackPlugin({
fsInlineContents: {
'preflight.js': fs.readFileSync(path.join(__dirname, 'src/preflight/preflight.js'), 'utf8'),
'preflight.css': fs.readFileSync(path.join(__dirname, 'src/preflight/preflight.css'), 'utf8')
}
})); and then in template I echo the contents out by doing <script><%= htmlWebpackPlugin.options.fsInlineContents['preflight.js'] %></script>
<style><%= htmlWebpackPlugin.options.fsInlineContents['preflight.css'] %></style> I haven't tried if html-webpack-inline-source-plugin could make me abandon |
Yeah, it gets tricky when you're dealing with assets that are being copied to the webpack output path. You need to make sure those assets are copied before htmlWebpackPlugin starts processing things or else you start to get unexpected results... Thanks for documenting your findings, and for the suggestions of using I'll take a look at those the next time I have assets that I want to copy and include. |
note that |
Hi,
I have a setup very similar to first example in the docs
preflight.js
exists and that is not (and should be not) added in webpack entry.copy-webpack-plugin
. On the way it receives hashing for filename itself which will change only when contents change.html-webpack-plugin
to generate template, i this example auto injecting default one.preflight.*.js
which would match stuff in webpack's output path (in my casepath: path.join(__dirname, 'public/assets')
)I tried both
**/*preflight.*.js
preflight.*.js
My test config is
Template output (prod build, not devserver) is
Whatever I put into
assets
key is outputted as is within template. As you can see from sourcefile name I am testing code splitting 😄 . Disabling that does not change anything.What am I missing? Did I overlook the docs and there is no actual minimatching against real files in filesystem that are copied over to output path?
Thanks!
The text was updated successfully, but these errors were encountered: