Tuesday 14 March 2017

Run Laravel Elixir in Gulp-runtime

I am a Laravel and NodeJS Developer. I am trying to use the laravel 5.3 elixir to run in a nodejs application I have. There are theme.json files with the styles, sass, scripts, est objects in them. I require those files and run the gulp-runtime. When I run the script Gulp runs but the Elixir does not. Any Suggestions?

My Module:

const elixir = require('laravel-elixir');
var _ = require('lodash');
var gulp = require('gulp-runtime').create();

module.exports = function(theme){
  elixir.config.assetsPath = '../../resources/themes/'+theme+'/assets/'; //trailing slash required for some reason.
  var theme = require('../../resources/themes/'+theme+'/theme.json');

  _.forOwn(theme.styles, function(subfiles, file) { //value, key
    console.log(subfiles) // Displays Correct Object,
    console.log(file) // Displays Correct Filename,
    gulp.task('default', function(arg){
      // Gulp starts but elixir does not run
       elixir((mix) => {
           mix.styles(subfiles, 'public/css/'+file)
      });
    });
    gulp.start('default');
  });
}

My Output:

    [12:37:13] Using gulpfile ~/Projects/myapp/app/cli/install-theme.js
[12:37:13] Start series(default)



via Trevor Varwig

No comments:

Post a Comment