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

Font urls does not work when using sourceMap #296

Closed
hoanguyen311 opened this issue Jul 3, 2016 · 12 comments
Closed

Font urls does not work when using sourceMap #296

hoanguyen311 opened this issue Jul 3, 2016 · 12 comments

Comments

@hoanguyen311
Copy link

hoanguyen311 commented Jul 3, 2016

webpack configuration:

modules: {
    loaders: [{
        test: /\.scss$/,
        loader: ['style', 'css?sourceMap', 'postcss',
            'sass?sourceMap'
        ].join('!')
    }, {
        test: /\.(mp4|ogg|svg|eot|ttf|woff|woff2|jpg|png)$/,
        loader: 'file-loader'
    }]
}

styles/fonts.scss

@font-face {
  font-family : "foundation-icons";
  font-style  : normal;
  font-weight : normal;
  src         : url(foundation-icons.eot);
  src         : url(foundation-icons.eot?#iefix) format("embedded-opentype"),
                url(foundation-icons.woff) format("woff"),
                url(foundation-icons.ttf) format("truetype"),
                url(foundation-icons.svg#fontcustom) format("svg");
}

And the font icons doesn't work
screen shot 2016-07-03 at 17 45 28

It's ok after I removed sourceMap option of css-loader
screen shot 2016-07-03 at 17 47 26

@hoanguyen311 hoanguyen311 changed the title Custom font does not work when using sourceMap Font urls does not work when using sourceMap Jul 3, 2016
@acidicX
Copy link

acidicX commented Jul 7, 2016

duplicate of #232 I think

@blowsie
Copy link

blowsie commented Aug 15, 2016

Only difference which this ticket is the source is sass and not css

@alexander-akait
Copy link
Member

@hoanguyen311 Error still exists?

@janvesel
Copy link

janvesel commented May 26, 2017

Yes I have same issue.

I made a workaround by:

  • separating css that loads fonts into separate file,
  • excluded this file from my regular scss loader (with sourceMap option set to true)
  • added additional loader (that includes only this file and without source files and without sourceMap),
  • imported new fonts file into app.js.
{
    test    : /\.scss$/,
    loader  : isProd ? ExtractTextPlugin.extract(['css-loader', 'sass-loader']) : 'style-loader!css-loader?sourceMap!sass-loader?sourceMap',
    include : [paths.src],
    exclude : [`${paths.src}/assets/styles/fonts.scss`]
  },
  {
    test    : /\.css$/,
    loader  : isProd ? ExtractTextPlugin.extract(['css-loader', 'sass-loader']) : 'style-loader!css-loader!sass-loader',
    include : [`${paths.src}/assets/styles/fonts.css`]
  }

@alexander-akait
Copy link
Member

@janvesel your use webpack v1?

@janvesel
Copy link

@evilebottnawi I use webpack v1.14

@alexander-akait
Copy link
Member

@janvesel can your upgrade config to v2 and tests again?

@Kaijun
Copy link

Kaijun commented Jul 6, 2017

@evilebottnawi webpack 2/3 doesn't work either.

@alexander-akait
Copy link
Member

@Kaijun can your create minimum reproducible test repo?

@alexander-akait
Copy link
Member

Closing due to inactivity. Please test with latest version and feel free to reopen if still regressions. Thanks!

@dgesteves
Copy link

I still have that problem, any solution?

@janvesel
Copy link

janvesel commented Feb 11, 2019

@EstevesDiogo I created a workaround by adding another loader for file that load fonts only and for that I didn't use sourceMap

{
    test    : /\.scss$/,
    loader  : isBuild ? ExtractTextPlugin.extract(['css-loader', 'postcss-loader', 'sass-loader']) : 'style-loader!css-loader?sourceMap!postcss-loader?sourceMap!sass-loader?sourceMap',
    include : [path-to-assets]
  },
{
    test    : /\.css$/,
    loader  : isBuild ? ExtractTextPlugin.extract(['css-loader', 'postcss-loader', 'sass-loader']) : 'style-loader!css-loader!sass-loader',
    include : [`path-to-assets/fonts.css`]
  },

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

No branches or pull requests

7 participants