Last active
August 28, 2017 19:05
-
-
Save ooflorent/d4116584cc45a19c835b to your computer and use it in GitHub Desktop.
Simplify extension management in webpack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ext = (...suffix) => new RegExp(`\\.(?:${ suffix.join('|') })(?:[?#].*)?$`) | |
const loaders = [ | |
// Traditional cases | |
{ test: ext('css'), loaders: ['style', 'css'] }, // single | |
{ test: ext('js', 'jsx', 'es6'), loaders: ['babel'] }, // multiple | |
// Complex case: Font-Awesome adds query strings and/or hashs to files | |
{ test: ext('otf', 'eot', 'svg', 'ttf', 'woff', 'woff2'), loaders: ['file?name=[name].[ext]'] }, | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment