brunch / with-react

React skeleton with Babel/ES6 for Brunch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Renaming "app" to something else

alberteddu opened this issue · comments

Hello!
I'm having some problems renaming the directory "app" to something else. So I renamed the directory, and changed brunch config like this:

module.exports = {
  files: {
    javascripts: {
      joinTo: {
        'vendor.js': /^(?!something)/,
        'app.js': /^something/
      }
    },
    stylesheets: {joinTo: 'app.css'}
  },

  plugins: {
    babel: {presets: ['es2015', 'react']}
  }
};

But brunch complains on "build":

warn: Nothing to compile. Most likely you don't have any source files yet, in which case, go ahead and create some! Otherwise, you probably don't have any plugin handling your source files (for plain javascript, that would be "javascript-brunch")

although it works fine with "app". What simple thing am I missing? :)

Thanks for your help!

Of course I realized what could be wrong immediately after sending this issue. It may be related to the paths.watched value which defaults to 'app', 'test', 'vendor'. I'm going to try and update this issue later.

Alright, so there are two additional required changes for this to work.
First of all, the one I mentioned:

paths: {
    watched: ['something', 'test', 'vendor']
},

but also

modules: {nameCleaner: (path) => path.replace(/^something\//, '') }

Because the default behavior of "modules" is:

modules: {nameCleaner: (path) => path.replace(/^app\//, '') }

Everything works now.

Spent an hour trying to figure this one out. This should really be documented better. In any case, why is the default behaviour of modules dependent on a folder named app?

that's how rails did it in 2006. Where else would you put it? src is a short-cut for source -- meh.

I would prefer src to app, mostly because that seems to be the common convention these days in the JS world.

I can fully understand the need to set paths.watched to include the folder name. But I'm sure you'll agree that it's not at all transparent that modules.nameCleaner is something that needs to be changed as well.