Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webpack replace only one file in library (bootstrap)

Tags:

webpack

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

like image 530
Alexandr Sulimov Avatar asked Nov 09 '17 16:11

Alexandr Sulimov


2 Answers

Maybe another alias that says:

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

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

like image 112
scipper Avatar answered Sep 30 '22 05:09

scipper


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' }
        ])
]
like image 22
Vignesh Avatar answered Sep 30 '22 03:09

Vignesh