teux / ng-cache-loader

Webpack loader to put HTML partials in the Angular's $templateCache.
83 stars 15 forks source link

How to use #37

Closed AGuyCoding closed 6 years ago

AGuyCoding commented 6 years ago

With a structure like that: +-- scripts +--- foo +----- a.js +--- bar +----- b.js

+-- views +--- foo +----- index.html +--- bar +----- index.html +--- shared +----- index.html


how can one import "views/bar/index.html" AND "views/shared/index.html" within "scripts/bar/b.js" ? the html files are all called the same "index.html", what can we do to "ng-include" both files?

AGuyCoding commented 6 years ago

Okay for others like me, this setup worked for me

inside webpack-2-config { test: /\.html$/, use: [{ loader: "ng-cache-loader", options: { prefix: path.join(__dirname, '/Views:[dirs]'), exportId: false, minimizeOptions: { removeComments: true, removeCommentsFromCDATA: true, collapseWhitespace: true, conservativeCollapse: false, preserveLineBreaks: true, removeEmptyAttributes: true, keepClosingSlash: true, }, }, }], }

the important part is the prefix so i can call the templates like <div ng-include="'someFolder/index.html'"></div> <br />