我想require/import作为字符串的HTML模板到我的代码。但运行在一些transpile错误。需要HTML文件作为模板字符串在Browserify使用tsify(打字稿)
这是revelant Browserify设置我使用:
browserify({ basedir: './src' })
.transform(stringify(['.tpl.html']))
.add('app.ts')
.plugin(tsify)
在app.ts我想导入模板,像这样:
import template from './app.tpl.html';
console.log(template);
凡app.tpl.html可能看起来像这样:
Hello!
我尝试了使用的不同设置超过import。使用require我得到以下错误:
Browserify Error { [TypeScript error: src/components/app.ts(1,9):
Error TS2304: Cannot find name 'require'.]
message: 'src/components/app.ts(1,9): Error TS2304: Cannot find name \'require\'.',
fileName: 'src/components/app.ts',
line: 1,
column: 9,
name: 'TypeScript error' }
Usind import模块没有找到,我得到以下错误:使用
Browserify Error { [TypeScript error: src/components/test.ts(1,22): Error TS2307: Cannot find module './test.tpl.html'.]
message: 'src/components/test.ts(1,22): Error TS2307: Cannot find module \'./test.tpl.html\'.',
fileName: 'src/components/test.ts',
line: 1,
column: 22,
name: 'TypeScript error' }
我找不到一个例子“字符串”和“tsify “在一起。有没有人可以使用HTML模板来处理“browserify”和“tsify”的工作示例?