Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run "compass" from "watch" through "newer" when '@import'-ed file has changed #55

Open
numediaweb opened this issue Aug 7, 2014 · 11 comments

Comments

@numediaweb
Copy link

in my Grunt file I have:

..

        compass: {
            dest: {
                outputStyle: 'compact',
                relativeAssets: true,
                files: {
                    '<%= destFolder %>/assets/css/main.css': "src/assets/scss/main.scss",
                }
            }
        },
        watch: {
            compass: {
                files: ['src/assets/scss/**/*.scss'],
                tasks: ['newer:compass:dest']
            }
        }
..

When I edit a partial *.scss, the "watch" task detects the changes but the "newer" task thinks nothing has changed so it doesn't run the compass on "main.scss".

I have seen an issue here #35 similar but with less.. is there any fix for sass?

@numediaweb numediaweb changed the title Run "compass" from "watch" through "newer" when "@import"-ed file has changed Run "compass" from "watch" through "newer" when '@import'-ed file has changed Aug 7, 2014
@numediaweb
Copy link
Author

I think newer is not suitable for compass in this case; I have only one main file "main.scss" that imports the rest of partials.. Which means I need to "compass" it all the time!

@numediaweb
Copy link
Author

I also tested it with Assemble and seems not working either; Assemble uses partials and layouts (the same way SASS uses imports) to compile pages.. when I update a partial, the watch task detects the change but "grunt-newer" ignores to run the assemble command because the layout didn't change..
So not really suitable for Assemble and SASS! (unless I'm missing something!)

@grayghostvisuals
Copy link

👍

@jzaefferer
Copy link

The documentation mentions an "override" option to check for partials: https://github.com/tschaub/grunt-newer#optionsoverride

Unfortunately implementing that checkForModifiedImports function is left as a non-trivial exercise for the reader. I'm wondering if there's a reference implementation somewhere.

@eush77
Copy link

eush77 commented Oct 23, 2014

Just encountered the same problem with Browserify.

@jzaefferer checkForModifiedImports is a placeholder.

According to the docs, override function is called with the file that is being considered “older” and can force it to be included anyways.

The default value for this option is the following. It won't affect anything.

function nullOverride(details, include) {
  include(false);
}

The simplest non-trivial thing is to include all files for the task no matter what.

grunt.config('newer', {
  options: {
    override: function (detail, include) {
      if (detail.task == 'browserify') {
        include(true);
      }
      else {
        include(false);
      }
    }
  }
});

Of course it is the same as not using grunt-newer for this task at all.

You can include some files in every build but still use grunt-newer to deal with the rest.

grunt.config('newer', {
  options: {
    override: function (detail, include) {
      if (detail.task == 'browserify') {
        if (detail.path.match('^lib/')) {
          include(true);
        }
        else {
          include(false);
        }
      }
      else {
        include(false);
      }
    }
  }
});

Important thing to remember is that grunt-newer will fire this function only for those files that are listed in the src config field for the task.

@JoshBeveridge
Copy link

Has anyone come up with a solution for this? I'm trying to use grunt-newer in a similar capacity with PostCSS where I have imported partials compiling the parent files by default. I suppose it would be difficult to check which files import the edited partial and then have grunt-newer check against those parents instead.

@tfrommen
Copy link

Hi there,

I just posted something over here, which might be of interest to you.

@eush77 @grayghostvisuals @joshdrink @jzaefferer

@CodySchaaf
Copy link

All these work arounds seem to just be doing newers job twice (like checking the mtime). Are the changed files not available to just pass into the override method?

@ConeyIsland
Copy link

Are we going to enter in 2018 with this feature (bug)? Solution with override is awful I think. It should be option with true/false value.

@tschaub
Copy link
Owner

tschaub commented Nov 29, 2017

@MonoStas - I think the answer to your question is yes. Unless someone contributes a solution.

@tschaub tschaub closed this as completed Nov 29, 2017
@tschaub tschaub reopened this Nov 29, 2017
@tschaub
Copy link
Owner

tschaub commented Nov 29, 2017

(Unintentionally closed after leaving that comment.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants