Question

I have a brunch config.coffee file located at ~/lens/v that includes these lines:

  files:
    javascripts:
      defaultExtension: 'coffee'
      joinTo:
        'javascripts/app.js': /^app/

Brunch takes files with a .js extension that are located in the root of the /app directory and concatenates them into app.js -- but it does not concatenate files that are located in /app's sub directories.

Specifically, I am trying to get brunch to add in a coffeescript file located at ~/lens/v/app/assets

~/lens/v/app/assets$ cat r.coffee 
d3.select("body").style("background-color", "black");

I am able to build the project like this

~/lens/v$brunch b

But when I search the app.js file for "d3" I can't find it. The JS is not getting concatenated for some reason.

grep -r "d3" app.js //returns nothing

This line from the config file javascripts/app.js': /^app/ should join any javascript file in /app to app.js. But this is not happening. I get the same behavior when I change the extension of my javascript file to .js (from .coffee).

What steps can I take to debug this?

Était-ce utile?

La solution

The issue is that Brunch has special handling for assets. They are treated differently from the files you wish to compile - copied as-is into your public directory.

The simplest way to solve the issue you're describing would be to move that coffeescript somewhere else under app, but not in assets.

Alternately, you could reconfigure what is treated as an asset in your brunch config under conventions.assets. https://github.com/brunch/brunch/blob/stable/docs/config.md#conventions

Autres conseils

I asked this exact same question a few days ago, and answered it here:

How can I compile individual CoffeeScript files in the assets directory?

If you want to keep those files in assets/, my solution is to use the After-Brunch plugin and convert them manually, as I show in the link above.

Otherwise, move them out of assets/, and use the coffeescript plugin in I linked to first.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top