How can I require a html template with Browserify

前端 未结 2 1912
鱼传尺愫
鱼传尺愫 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:31

    Good option is jstify.

    browserify ./app/main.js -t jstify > static/bundle.js
    

    For more information take a look this link

    0 讨论(0)
  • 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
    
    0 讨论(0)
提交回复
热议问题