URL rewriting in webpack

I use webpack to link files and import CSS. Inside the CSS file included in bootstrap, there is a link to the font / fonts / glyphicons -halflings-regular.ttf.

Is there a way to instruct webpack to mount files from / node_modules / bootstrap-css-only / fonts / to / fonts? Or rewrite HTTP request through webpack dev server based on regex expression?

Sorry if this is super basic, new to webpack.

+5
source share
1 answer

You can use the file loader and adjust the variable [path]:

loaders: [ { test: /\.(png|jpg|svg|ttf|eot|woff|woff2)$/, loader: 'file?name=[path][name].[ext]' // your case: 'file?name=fonts/[name].[ext]' } ... ], 

In this case, all associated files will be placed in the "fonts /" folder.

+2
source

Source: https://habr.com/ru/post/1234413/


All Articles