karma-ng-html2js-preprocessor icon indicating copy to clipboard operation
karma-ng-html2js-preprocessor copied to clipboard

having to create separate path and shim for every template with require.js

Open dagda1 opened this issue 8 years ago • 0 comments

I have inherited an angularjs project that uses requirejs and I am (obviously) using your great project to preprocess the html files into js.

My karma.conf.js looks like this:

    preprocessors: {
      "./application/**/*.html": ["ng-html2js"]
    },

    ngHtml2JsPreprocessor: {
      stripPrefix: 'application/',
      prependPrefix: '/application/',
      moduleName: 'coms.templates'
    },

The problem I have is that I need to add an extra entry in the requirejs and paths section for every template I add, e.g.

paths: {
   angular: 'libs/vendors/angular/angular-1.4.7.min',
   angularMocks: '../node_modules/angular-mocks/angular-mocks',
   invoiceSearch: 'invoices/views/invoiceSearch.html'
},
shims: {
  'angular': {
    exports: 'angular'
  },
  angularMocks: {
    deps: [ 'angular' ],
    exports: 'angularMocks'
  },
  invoiceSearch: {
    deps: [ 'angular' ],
    exports: 'invotceSearch'
   },
}

If I don't do this then I get a can't find variable angular for every template that is not added in this way, is there a way I can create an entry for all templates?

dagda1 avatar Mar 20 '16 21:03 dagda1