webpack-contrib / style-loader

Style Loader
MIT License
1.65k stars 473 forks source link

Using injectType linkTag with webpack leads to url being an esModule #428

Closed 4iAmAve closed 4 years ago

4iAmAve commented 4 years ago

Expected Behavior

The injected link tag should reference the correct link URL.

Actual Behavior

The passed url parameter into the link tag function is an esModule (for whatever reason) as follows:

{
  "default": "//localhost:4001/main.css"
}

Hence the appended <link /> child looks like this:

<link rel="stylesheet" href="[object Module]">

No matter whether we use import './main.css' or require('./main.css'); in our component code. Even import styles from './main.css' does not help.

Code

    {
        test: /\.css$/,
        use: [
          {
            loader: 'style-loader',
            options: {
              injectType: 'linkTag'
            }
          },
          {
            loader: 'file-loader',
            options: {
              name: 'main.css',
            },
          },
        ]
      },
alexander-akait commented 4 years ago

Thanks for issue :+1:

4iAmAve commented 4 years ago

@evilebottnawi Shall I provide a PR?

alexander-akait commented 4 years ago

@4iAmAve no need, i already WIP on this :+1:

4iAmAve commented 4 years ago

@evilebottnawi

Thanks a lot. That went fast. :)