0

I'm trying to build a pipeline to deploy my website. I use grunt to compile less and minify CSS. This is how the gruntfile.js looks like:

  module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    less:{
      development: {
         options: {
            path: ["assets/less/*.less"]
         },
         files: { "assets/css/style.css" : "assets/less/style.less" }
      }
   },
     cssmin: {
       options: {
          sourceMap: false,
       },
       target: {
          files: {"assets/css/style.min.css": "assets/css/style.css"}
       }
    },
  });

  // Load the plugin that provides the "uglify" task.
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-less');
  // Default task(s).
  grunt.registerTask('default', ['less','cssmin']);

};

this is the package.json file:

{
  "name": "lr-experience-builder",
  "version": "0.1.0",
  "devDependencies": {
    "assemble-less": "^0.7.0",
    "grunt": "^0.4.5",
    "grunt-contrib-cssmin": "^1.0.2",
    "grunt-contrib-jshint": "~0.10.0",
    "grunt-contrib-less": "^1.4.0",
    "grunt-contrib-nodeunit": "~0.4.1",
    "install": "^0.8.1",
    "npm": "^3.9.2"
  }
}

I install the package in the pipeline in buddy.work, but everytime when I ran this pipeline, it throughs this error:

.......
Creating image finished.
grunt
Loading "less.js" tasks...ERROR
>> Error: Cannot find module './lodash'
Warning: Task "less" not found. Use --force to continue.
Aborted due to warnings.
Build failed !!!.

and this is how i config in the buddy.work pipeline:

npm install
npm install -g grunt-cli
npm install grunt --save-dev
npm install grunt-contrib-less --save-dev
npm install grunt-contrib-cssmin --save-dev

Does anyone have any ideas?

Kyle
  • 135
  • 1
  • 12

1 Answers1

0

In your pipeline packages & setup commands, do this:

npm install -g grunt-cli
npm install lodash
npm install grunt --save-dev
npm install grunt-contrib-less --save-dev
npm install grunt-contrib-cssmin --save-dev

In the run command section do:

npm install
grunt

btw, check to clean cache when you ready to deploy.

Kyle
  • 135
  • 1
  • 12