extract-loader
extract-loader copied to clipboard
Doesn't work with aliases properly
When WebPack has aliases propery:
module.exports = {
...
resolve: {
extensions: ['.js'],
alias: {
default: path.resolve(__dirname, 'default'),
'./default': path.resolve(__dirname, 'default'),
}
}
}
and extract-loader
is being used with an html-loader
module.exports = {
...
module: {
rules: [
{
test: /\.html$/,
use: [
{
loader: 'extract-loader',
},
{
loader: 'html-loader',
}
]
}
]
}
...
}
end temple that uses aliases default
:
<img src="default/course-default.jpg" />
...
<img src="images/logo.svg" alt="">
extract-loader
- gives me an error:
Error: Cannot find module './default/course-default.jpg' from '/webpack-demo/src'
But with the same configuration and old version "extract-loader": "^2.0.0"
- everything is working just fine!
Is there something wrong happening with the extract-loader?
@wizardion I ran into the same issue, caused by extract-loader
attempting to resolve requires without considering aliases.
I forked the repo and fixed this issue - you can always try and giving it a spin to see if it works for you as well.
@vseventer I resolved my problem by getting rid of this horrible extract-loader
in my main HTML file template. The extract-loader
also brokes my AngularJS templates in my project.
I used it only for ejs
variables in my main HTML template, within such configuration:
module: {
rules: [
{
test: /\.html$/,
use: [
"ejs-loader",
"extract-loader",
"html-loader"
]
}
]
}
So I changed the main template of my application to *.ejs
file extension to allow my HtmlWebpackPlugin
to serve the the ejs
variables and got rid of extra loaders. The "html-loader" is still in use for all other HTML files in my project.
But the main issue with this loader is still present, and I don't know why it's not going to be fixed for so long time... 'cause this issue exists from v3.0.0. It's frustrating by spending so much time figuring out for just a simple problem.
Can we get this PR merged in and released? I'm having the same alias issue.