Thursday, November 23, 2017

webpack replace only one file in library (bootstrap)

Leave a Comment

In project used angular 2 + webpack + bootstrap

I want use custom theme for bootstrap - replace node_modules/../bootstrap.css with ./Content/bootstrap.min.css

I add alias for that

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 I can replace a file but not change the folder for depend resources

example

glyphicons-halflings-regular.eot must be searched in \node_modules not in Content

2 Answers

Answers 1

Maybe another alias that says:

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

Seems a bit hacky, but maybe give it a try.

Answers 2

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

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

  resolve: {         extensions: ['.ts', '.js'],         alias: {             assets$: path.resolve(__dirname, './Content'),                   }     },  plugins: [         new CopyWebpackPlugin([             { from: 'bootstrap/dist/css/bootstrap.css', to: './Content' }         ]) ] 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment