Webpack replaces only one file in the library (bootstrap)

In the used project angular 2 + webpack + bootstrap

I want to use a special download theme - replace node_modules /../ bootstrap.css with ./Content/bootstrap.min.css

I add an alias for this

alias: { 'bootstrap/dist/css/bootstrap.css': './Content/bootstrap.min.css', } 

but have errors

 Can't resolve '../fonts/glyphicons-halflings-regular.eot' in '\Content' @ ./Content/bootstrap.min.css 

How can I replace the file but not change the folder for dependent resources

Example

glyphicons-halflings-regular.eot need to be searched in \ node_modules not in content

+7
webpack
source share
2 answers

Perhaps another alias that states:

 './Content/fonts': 'node_modules/bootstrap/dist/fonts' 

It seems a bit hacky, but maybe try it.

+1
source share

You can use CopyWebpackPlugin to load css, js file.Try this code

npm install copy-webpack-plugin --save-dev

  resolve: { extensions: ['.ts', '.js'], alias: { Content$: path.resolve(__dirname, './Content'), } }, plugins: [ new CopyWebpackPlugin([ { from: 'bootstrap/dist/css/bootstrap.css', to: './Content' } ]) ] 
+1
source share

All Articles