Closed rokoroku closed 7 years ago
If the [hash]
is already in your filename, then aren't you using webpack to generate that css file?
If so, then it should already be included in the style assets being injected to the html-webpack-plugin
template.
The main motivation for html-webpack-include-assets-plugin
is to provide a means to include non webpack generated assets in the html templates.
Can you provide more information about what you're trying to do?
it's a humble example,
[
new CopyWebpackPlugin([
{ from: 'assets/styles.css', to: 'dist/style.[hash].css' },
]),
new HtmlWebpackPlugin({
template: 'assets/index.html'
}),
new HtmlWebpackIncludeAssetsPlugin({
assets: ['dist/style.[hash].css'],
append: false
})
]
In my scenario, the styles.css
is built by another task (outside of gulp), I have to use CopyWebpackPlugin.
But when I template the filename with compilation hash, this plugin can't include the assets.
Of course I can use the hash
option, but I prefer filename hash. That's why I'm suggesting this feature.
Or.. can we support directory or glob pattern for including assets? It will solve my problem too.
Just published version 0.0.8
with support for asset.glob
. See the updated README for an example. Please let me know if you encounter any issues with the new feature.
I can't get this to work with the added hash to the filename of CopyWebpackPlugin, and the examples in the README doesn't show this either. So can you add the example or tell me how to do this?
It it is not possible, then this issue should be reopened
@dietergeerts Can you post an example of what you’re trying to do? I don’t personally use the hash function so an example would allow me to explore if the newer versions of CopyWebpackPlugin have changed and broken something related to hashes
plugins: [
new CopyWebpackPlugin([{
context: path.resolve(__dirname, './../node_modules/@---/meteor-client/.build-client'),
from: 'meteor-client.js',
// to: '[name].[hash].[ext]', // >> This doesn't work together with HtmlWebpackIncludeAssetsPlugin
// and HtmlWebpackPlugin, see https://github.com/jharris4/html-webpack-include-assets-plugin/issues/12
}]),
new HtmlWebpackIncludeAssetsPlugin({
assets: ['meteor-client.js'],
append: false,
hash: true,
}),
new HtmlWebpackPlugin({
filename: '../index.html',
template: '../src/index.hbs',
alwaysWriteToDisk: true, // It's not detected in memory with dev-server!
settings: { base: options.base },
}),
],
This plugin brilliantly works with using copy-webpack-plugin together.
However, it cannot handle filename template such as
style.[hash].css
.It would be better when filename templating is supported.
https://github.com/webpack/loader-utils#interpolatename