使用webpack 2从html文件导入动态生成的脚本

时间:2017-08-06 05:10:58

标签: angularjs typescript webpack webpack-2

我正在使用typescript迁移到webpack,我有一些动态生成到我的index.html中的脚本,如此

<script>(function(modules) { code inside ... })</script>

如何将此脚本中的代码(相当直接编译的脚本到javasript代码)导入到我的main.ts文件(入口点)?例如

import whateverFunction from 'index.html'

当然这不起作用,但我希望看到正确的方法来实现它。提前致谢。

1 个答案:

答案 0 :(得分:0)

如果你在index.html上定义了一个变量,并且你想在typescript中使用它,你需要这样做:

declare var prod: boolean;
declare var version: string;

export class whateverName{
}

您应该使用与index.html文件中使用的名称相同的名称。

相关问题