When I do require('./something.html')
in my code and configure file-loader to load html files something like this:
...
module: {
rules: [
{test: /\.html$/, loader: 'file-loader', options: {name: '[name].[hash].html'}
},
}
...
Currently this will copy the original files to the configured output directory and replaces the require
calls to those filenames with the generated file url. Which works perfectly.
I'm wondering if it's possible to further process the files in someway like further minification or optimizationusing any other loaders. Or perhaps process them to optimize in some way using any hooks or similar. Not sure if webpack
provides that kind of hooks.
Is there any workaround to do this with file-loader
?
I tried something like this but it doesn't seem to work. It's not minified.
{
test: /\.html$/, use: [
{loader: 'raw-loader'},
{loader: 'html-minify-loader'},
{loader: 'file-loader'}
]
}
Let me know if anybody has any workaround for this using webpack 2. Thanks.
Note:
I know there is html-webpack-plugin for generating index.html
which is not what I'm looking for. I'm working in angular js 1.x project and there are numerous template html files which I'm requiring using file-loader
in the templateUrl
to load them on the fly which already works great. Now I only need to minify those output template files.