A
A
Alex Wells2016-04-15 19:31:52
Node.js
Alex Wells, 2016-04-15 19:31:52

Laravel Elixir + require angular?

Hello. There is a site on the latest laravel'e (5.2), it costs elixir, bower, npm, node. Actually I'm trying to fasten elixir-angular-template-cache from npm'a. There is this code:

var elixir = require('laravel-elixir');

require('elixir-angular-template-cache');

elixir(function(mix) {
    mix.angulartemplatecache({
        standalone: true
    }, 'resources/assets/js/app/templates/**/*.html', 'resources/assets/js/app');
});

Elixir itself works fine, only angulartemplatecache does not work. Here is the error:
TypeError: mix.angulartemplatecache is not a function
. Moreover, if I insert the contents of the index.js file of that same module directly into gulpfile.js - everything works! It doesn't work if you use the require. construct. I don't understand what's wrong.
node js v5.10.1
npm 3.8.3
UPD: it feels like these are different instances, but it's not clear what to do with it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kolesnikov, 2016-04-15
@Alex_Wells

I'm not sure if this is correct, but I did it this way.
I did not use the elixir package, because they often work with errors.
Nothing prevents you from using "gulp-angular-templatecache", which works 100%
The implementation turned out like this

var gulp = require('gulp');
var templateCache = require('gulp-angular-templatecache');

var Task = elixir.Task;

// Создание новой задачи
elixir.extend('templateCache', function() {

    new Task('templateCache', function() {
        return gulp.task('templateCache', function () {
            return gulp.src('resources/assets/js/**/*.html')
                .pipe(templateCache('templateCache.js', { module:'app'}))
                .pipe(gulp.dest('resources/assets/js/'));
        });

    }).watch('resources/assets/js/**/*.html');

});

elixir(function(mix) {
  // Добавляем задачу в микс
  mix.templateCache();
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question