Remove "dist" string from build with Webpack

Asked

Viewed 17 times

1

I created a rule in my file webpack.config.js so I can work with sources inside my scss, but when I do the build for production the string to load the file is as:

/distfonts/minha_font.woff

Where the folder is just fonts/minha_font.woff

Rule used in webpack:

{
  test: /\.(eot|svg|ttf|woff|woff2)$/i,
  loader: 'file-loader?name=fonts/[name].[ext]'
},

The current output is:

@font-face {
    font-family: hk_groteskmedium;
    src: url(/distfonts/hkgrotesk-medium-webfont.woff2) 
    format("woff2"),url(/distfonts/hkgrotesk-medium-webfont.woff) 
    format("woff");
    font-weight: 400;
    font-style: normal
}

The right way out would just be src: url(fonts/hkgrotesk-medium-webfont.woff2)

  • It’s been a while since I’ve touched Webpack but if you put the path as relative it changes something? loader: 'file-loader?name=./fonts/[name].[ext]'

  • if I put ./fonts the output stays /dist./fonts

  • Well, I think my last suggestion would be to try the argument outputPaths. 'file-loader?name=fonts/[name].[ext]'&outputPath=fonts/. Have a legal example on this link: https://github.com/webpack-contrib/file-loader

  • I have tried, in the same way keep putting this string dist at first

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.