Skip to content

y8n/inline-template-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

inline-template-loader

Install

npm install inline-template-loader

Usage

// webpack.conf.js

module: {
  rules:[{
    test: /\.js$/,
    loader: 'inline-template-loader'
  }]
}

Output

// index.js
function foo(){
  return __inline('./template.html');
}
// template.html
<div class="template">
  <h1>HelloWorld</h1>
</div>
// output.js
function foo(){
  return '<div class="template"><h1>HelloWorld</h1></div>';
}

options

// webpack.conf.js

module: {
  rules:[{
    test: /\.js$/,
    loader: 'inline-template-loader',
    options: {
      pattern: /__template(/    // 正则
      replcement: function(m){  // 替换方法
        return m.slice(1);
      }
    }
  }]
}

License

MIT

About

a webpack loader to inline template as string

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published