Препроцессор html2js удаляет несколько префиксов
У меня есть файловая структура, в которой шаблоны расположены в разных папках, но задача сборки помещает их все в одну папку. Я хочу убрать все префиксы из файлов и добавить правильный префикс сборки.
Это работает, чтобы загрузить все шаблоны
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
Заранее спасибо.
1 ответ
Решение
Вы, наверное, ищете это
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;
},
}
Это описано в репо. https://github.com/karma-runner/karma-ng-html2js-preprocessor