Skip to content

Instantly share code, notes, and snippets.

@yjaaidi
Created November 13, 2016 20:38
Show Gist options
  • Save yjaaidi/fce2464826281d80207dd97277874881 to your computer and use it in GitHub Desktop.
Save yjaaidi/fce2464826281d80207dd97277874881 to your computer and use it in GitHub Desktop.
Webpack Dynamic File Name Resolution
/*
* Webpack config
*/
/* Use file-loader for images. */
{
test: /\.(gif|ico|jpg|png|svg)$/,
loader: 'file'
}
/* User file-loader for html files ending with 'async.html'. */
{
test: /\.async\.html$/,
loader: 'file'
}
/*
* Your js/ts code.
*/
let logoUrl = require(`./logo-${companyId}.png`);
/* You can also customize your templates depending on some context variable.
* In this example we suppose we are using ionic or nativescript and we want to use different templates depending on the OS. */
const os = 'ios';
@Component({
templateUrl: require(`./my-cool-button.${os}.component.async.html`)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment