linemanjs / lineman

Lineman helps you build fat-client JavaScript apps. It produces happiness by building assets, mocking servers, running specs on every file change
MIT License
1.18k stars 83 forks source link

How to specify the order of the files concatenated into app.css? #246

Closed kgodard closed 10 years ago

kgodard commented 10 years ago

On our project, when generating app.css, previous versions of lineman added our compiled LESS css after our vendor css files, like:

vendor1.css
vendor2.css
our_project.css (compiled as app.less.css)

In the latest version of lineman as of this minute (0.28.3), it's concatenating the CSS files in the opposite order, with our project CSS (app.less.css) first, then the vendor CSS.

here's the top of our app.css.map file, in which you can see the order of the included files:

{
  "version": 3,
  "file": "app.css",
  "sources": [
    "generated/css/app.less.css",
    "vendor/css/iosOverlay.css",
    "vendor/css/jquery.mobile.custom.structure.css",
    "vendor/css/jquery.mobile.custom.theme.css"
  ],

This is causing problems because there are a few things that in the vendor CSS that we've overridden in our styles.

I've searched through all of the config files in lineman for a way to specify the order, but I can't figure out where it's being specified.

our config/files.coffee:

module.exports = require(process.env['LINEMAN_MAIN']).config.extend("files",

  less:
    main: "app/css/main.less"
    app: "app/css/**/*.less"
    vendor: "vendor/css/**/*.less"
    generated: "generated/css/app.less.css"

  js:
    spec: "spec/js/**/*.js"
    specHelpers: "spec/js/helpers/**/*.js"
    vendor: [
      "vendor/js/underscore.js",
      "vendor/js/jquery.js",
      "vendor/js/backbone.js",
      "vendor/js/**/*.js"
    ]

  coffee:
    app: [
      "app/js/config/**/*.coffee",
      "app/js/api/base.coffee",
      "app/js/api/**/*.coffee",
      "app/js/models/**/*.coffee",
      "app/js/formatter.coffee",
      "app/js/**/*.coffee"
    ]
    spec: "spec/js/**/*.coffee"
    specHelpers: "spec/js/helpers/**/*.coffee"

  css:
    vendor: ["vendor/css/bootstrap.css", "vendor/css/**/*.css", "vendor/css/bootstrap-responsive.css"]
)

lineman/config/plugins/concat_sourcemap.coffee (unaltered):

module.exports = (lineman) ->
  config:
    concat_sourcemap:
      options:
        sourcesContent: true

      js:
        src: [
          "<%= files.js.vendor %>"
          "<%= files.template.generated %>"
          "<%= files.js.app %>"
          "<%= files.coffee.generated %>"
        ]
        dest: "<%= files.js.concatenated %>"

      spec:
        src: [
          "<%= files.js.specHelpers %>"
          "<%= files.coffee.generatedSpecHelpers %>"
          "<%= files.js.spec %>"
          "<%= files.coffee.generatedSpec %>"
        ]
        dest: "<%= files.js.concatenatedSpec %>"

      css:
        src: [
          "<%= files.sass.generatedVendor %>"
          "<%= files.css.vendor %>"
          "<%= files.sass.generatedApp %>"
          "<%= files.css.app %>"
        ]
        dest: "<%= files.css.concatenated %>"

css section of lineman/config/files.coffee (unaltered):


  css:
    vendor: "vendor/css/**/*.css"
    app: "app/css/**/*.css"
    concatenated: "generated/css/app.css"
    minified: "dist/css/app.css"
    minifiedWebRelative: "css/app.css"
davemo commented 10 years ago

The latest version of lineman utilizes lineman-less, which has its own plugin configuration. Much of your existing config/application.coffee can be deleted. The parts that are relevant to keep are coffee.app and js.vendor. I would try removing the rest and see if that sorts your problem out. Chances are your userland config is overly specific and is conflicting with the config leftover from previous versions of lineman that contained that stuff in core instead of plugin configs.

If you use the latest version of Lineman, and generate a new app structure (lineman new my-app) you can see just how little is included by default in config/application.coffee and config/files.coffee for a comparison :)

kgodard commented 10 years ago

Dave, thanks for the pointer in the right direction. It was in fact the lineman-less plugin config that was causing the issue. This fixed it:

config/application.coffee

  concat_sourcemap:
    css:
      src: [
        "<%= files.css.vendor %>"
        "<%= files.css.app %>"
        "<%= files.less.generated %>"
      ]