0

When I run lineman build it generates all the minified CSS and JS in the /dist directory. I can't figure out how to make it copy those minified files into a different directory( My Public Directory at path - ../lib/app/public).

My Lineman configuration file looks like this.

# Exports an object that defines
#  all of the configuration needed by the projects'
#  depended-on grunt tasks.
#
# You can familiarize yourself with all of Lineman's defaults by checking out the parent file:
# https://github.com/testdouble/lineman/blob/master/config/application.coffee
#

module.exports = require(process.env['LINEMAN_MAIN']).config.extend('application', {
  removeTasks:
    common: [ "webfonts:dev", "images:dev"]
    dist: ["images:dist", "webfonts:dist", "pages:dist"]

  server:
    apiProxy:
      enabled: true
      host: 'localhost'
      port: 4567

  # enableSass: true

  # configure lineman to load additional angular related npm tasks
  loadNpmTasks: [ "grunt-ngmin"]

  # task override configuration
  prependTasks:
    dist: ["ngmin"]         # ngmin should run in dist only

  watch:
    scripts:
      files: ["generated/**"],
      tasks: ['copy:dev']

  copy:
    dev:
      files: [expand: true, cwd: 'generated', src: ['css/**', 'js/**', '!**/spec.js', 
              '!**/*.less*', '!**/*.coffee*', '!**/*.*.map'], dest: '../lib/app/public' ]

  # configuration for grunt-ngmin, this happens _after_ concat once, which is the ngmin ideal :)
  ngmin: {
    js: {
      src: "<%= files.js.concatenated %>",
      dest: "<%= files.js.concatenated %>"
    }
  },
})

I know there is a copy:dist default task in Lineman but not sure how it works and can't understand it properly from the documentation at http://linemanjs.com/

Praveen Puglia
  • 5,577
  • 5
  • 34
  • 68

1 Answers1

0

I solved this problem, with Lineman's help:

  • Wrote a custom task, tasks/dl-dev-copy.js, to copy the files:

    module.exports = function(grunt) {
       return grunt.registerTask('dl-dev-copy', 'Copy UI artifacts to wildfly deployment folder', ['copy:dl-dev-copy']);
    };
    
  • Updated the application.js file (the key part is important, I was only able to figure it out after the Lineman folks helped me out):

    loadNpmTasks: lineman.config.application.loadNpmTasks.concat('grunt-contrib-copy'),
       copy: {
          'dl-dev-copy': {
            files: [{
                expand: true,
                cwd: 'generated/',
                src: ['**'],
                dest: '../../../target/iq/'
            }]
        }
    },
    watch: {
        target: {
            "files": ["app/**/*", "spec/**/*", 'spec-e2e/**/*'],
            "tasks": 'dl-dev-copy'
        }
    },
    appendTasks: {
        common: ["dl-dev-copy"]
    }
    
  • See below for the output of lineman run (it is similar when a file is being watched changes, and we I run lineman build):

    lineman run
    Running "common" task
    ...       
     Running "copy:dl-dev-copy" (copy) task
    Created 6 directories, copied 23 files
    ...
    Running "watch" task
    Waiting...
    
Rodrigo Silveira
  • 141
  • 2
  • 15