rioct-loader

2019-11-17

rioct-loader是什么

什么是rioct-loader,rioct templates webpack loader

rioct-loader使用教程帮助文档

rioct-loader

rioct-loader is the webpack loader for Rioct templates.

Allows to require() template source files directly from JavaScript, letting Webpack compile them and put in the bundle.

Installation

Install in your Webpack build directory with:

npm install --save-dev rioct-loader

Configuration

Modify webpack.config.js (or any other Webpack config file):

module.exports = {
  // ...
  module: {
    // ...
    loaders: [{
      test: /\.tag.html?$/,    // or another file extension of your choice
      loader: "rioct-loader"   // or with options: "rioct-loader?trace=false&brackets={{ }}&useRioctRuntime=true"
    }]
    // ...
  }
  // ...
}

Usage

From JavaScript and React:

// === if it's a stateless component ===
const MyComponent = require("./my-component.tag.html");

// === if it's a stateful component ===
class MyComponent extends React.Component {
   render = require("./my-component.tag.html");
}

ReactDOM.render(React.createElement(MyComponent), document.body);

How it works

When building the bundle, Webpack will intercept all require() with filenames ending in .tag.html, then it calls rioct-cli to compile the template and the resulting code is given as result for the require() call.


上一篇:react-style-tag
下一篇:rioct-cli
相关文章

首次访问,人机识别验证

扫描下方二维码回复 1024 获取验证码,验证完毕后 永久 无须验证

操作步骤:[打开微信]->[扫描上侧二维码]->[关注 FedJavaScript 的微信] 输入 1024 获取验证码

验证码有误,请重新输入