How can I require a html template with Browserify

前端 未结 2 1911
鱼传尺愫
鱼传尺愫 2021-02-20 10:03

I\'m trying to figure out an easy way to require a html template in the script and then run browserify from the CLI.

Say I want to grab a template and append it to the b

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-20 10:51

    Use: https://github.com/substack/brfs

    1

    npm install brfs

    2

    var fs = require('fs');
    var html = fs.readFileSync(__dirname + '/robot.html', 'utf8');
    console.log(html);
    

    3

    browserify -t brfs example/main.js > bundle.js
    

提交回复
热议问题