Nicolas S.Xu
Nicolas S.Xu

Reputation: 14544

how to config webpack loader exclude path that contains 'fonts'

{   test: /\.(png|jpg|gif|svg)$/, 
    loader: 'url?limit=10000&name=/Presentation/_dist/images/[name].[ext]', 
    exclude: path.resolve(__dirname, "MY-FONTS-FOLDER")
}

Some fonts file name are ended with SVG, so I'd like to exclude any files that its path contains 'fonts', e.g: 'C:\project\app\module\fonts', 'C:\project\app\module2\fonts'.

The problem is the program is loader test condition seems only apply to file name, or specific path, but how can I test path string contain any 'fonts' string?

Upvotes: 1

Views: 3329

Answers (2)

Blai Samitier
Blai Samitier

Reputation: 179

You can pass a regular expression inside exclude that selects all font folders. For example:

{   
    test: /\.(png|jpg|gif|svg)$/, 
    loader: 'url?limit=10000&name=/Presentation/_dist/images/[name].[ext]', 
    exclude: /(\/fonts)/
}

Upvotes: 1

M. A. Cordeiro
M. A. Cordeiro

Reputation: 479

Try to use it:

{   
   test: /\.(png|jpg|gif|svg)$/, 
   loader: 'url?limit=10000&name=/Presentation/_dist/images/[name].[ext]', 
   exclude: /MY-FONTS-FOLDER/
}

Upvotes: 0

Related Questions