Skip to content

Intersec/html-dedup-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

html-dedup-loader

A loader for webpack that allows importing files with html-loader, but avoids applying it twice.

This is useful when using webpack with a heterogeneous codebase, that can include both:

  • imports of html assets with requireJS and the text plugin:
require('text!file.html');
  • imports of html assets directly
require('file.html');

Configuration

Use both a rule for all html imports, and a resolveLoader alias for the text plugin:

// webpack.config.js
module.exports = {
  module: {
    rules: [{
      test: /\.html$/,
      use: 'html-loader'
    }]
  },
  resolveLoader: {
    alias: {
      text: 'html-dedup-loader'
    }
  }
}

Without the loader alias, the text! prefix would make webpack fail. And without the html loader rule, the require without the text! prefix would not work.

About

Webpack loader to apply html-loader only once

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors