Skip to content
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

Doesn't work with aliases properly #81

Open
wizardion opened this issue Apr 21, 2020 · 3 comments · May be fixed by #82
Open

Doesn't work with aliases properly #81

wizardion opened this issue Apr 21, 2020 · 3 comments · May be fixed by #82

Comments

@wizardion
Copy link

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?

vseventer added a commit to vseventer/extract-loader that referenced this issue Apr 23, 2020
@vseventer
Copy link
Contributor

@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.

@wizardion
Copy link
Author

@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.

@vseventer vseventer linked a pull request Apr 24, 2020 that will close this issue
vseventer added a commit to vseventer/extract-loader that referenced this issue May 10, 2020
@boroth
Copy link

boroth commented May 19, 2021

Can we get this PR merged in and released? I'm having the same alias issue.

boroth added a commit to LeadingReach/extract-loader that referenced this issue May 20, 2021
gl84 pushed a commit to gl84/extract-loader that referenced this issue Sep 11, 2021
langri-sha pushed a commit to langri-sha/extract-loader that referenced this issue Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants