0

我有一个文件结构,其中模板位于不同的文件夹中,但构建任务将它们全部放入一个文件夹中。我希望从文件中删除所有不同的前缀并添加正确的构建前缀。

这可以加载所有模板

preprocessors: {
    'src/components/**/*_template.html': ['ng-html2js']
}

我在预处理器中寻找相同的功能,像这样

ngHtml2JsPreprocessor: {
    stripPrefix: "src/components/**",
    prependPrefix: "/assets/components",
    moduleName: "templates"
},

有没有办法删除直到 template.html 的整个前缀?

我的文件夹结构如下:

src
    components
        email
            directive.js
            service.js
            email_template.html
        phone
            directive.js
            service.js
            phone_template.html

构建文件夹如下

build
    assets
        components
            email_template.html
            phone_template.html

提前致谢。

4

1 回答 1

2

你可能正在寻找这个

ngHtml2JsPreprocessor: {
  //  define a custom transform function
  // - cacheId returned is used to load template
  //   module(cacheId) will return template at filepath
  cacheIdFromPath: function(filepath) {
    // example strips 'public/' from anywhere in the path
    // module(app/templates/template.html) => app/public/templates/template.html
    var cacheId = filepath.strip('public/', '');
    **do whatever you need to construct the path**
    return cacheId;
  },
}

它在 repo 中有描述。https://github.com/karma-runner/karma-ng-html2js-preprocessor

于 2016-04-04T23:41:43.817 回答