These are chat archives for brunch/brunch

1st
Aug 2016
John Grimes
@johngrimes
Aug 01 2016 20:29
how do i get brunch to only compile in my npm dependencies, and skip my devDependencies?
herenow
@herenow
Aug 01 2016 20:30
Include your npm dependencies in the bundle?
John Grimes
@johngrimes
Aug 01 2016 20:31
do i have to do that explicitly for each dependency? or does the npm integration handle that?
herenow
@herenow
Aug 01 2016 20:31
You have to require each dependency, brunch will only include the dependencies you require in the bundle.
or you can define them in npm.globals, http://brunch.io/docs/config#-npm-
John Grimes
@johngrimes
Aug 01 2016 20:35
ok, thanks
John Grimes
@johngrimes
Aug 01 2016 21:41
@herenow so, explicitly including my dependencies in the bundle looks something like this:
javascripts: {
  joinTo: {
    'app.js': [
      /^node_modules\/react\//,
      /^node_modules\/react-dom\//,
      /^node_modules\/react-redux\//,
      /^node_modules\/react-redux-form\//,
      /^node_modules\/redux\//,
      /^app/
    ],
  }
},
is this what you meant? this seems to suffer from the problem that dependencies of the dependencies are not included
Mauro Oviedo
@moviedo
Aug 01 2016 21:42
@johngrimes
Mauro Oviedo
@moviedo
Aug 01 2016 21:43
that's wrong
herenow
@herenow
Aug 01 2016 21:43
try to do something like this
is brunch not finding your npm modules?
John Grimes
@johngrimes
Aug 01 2016 21:44
i will try that again
when i've tried that in the past, all the node_modules were getting compiled in, ended up with 3MB of js
Mauro Oviedo
@moviedo
Aug 01 2016 21:45
npm is enabled by default, you don't even need to do the above that @herenow suggest. You can do something like the following:
files: {
    javascripts: {
      joinTo: {
        'javascripts/app.js': /^app\//,
        'javascripts/vendor.js': /^(?!app\/)/
      }
    },
    stylesheets: {
      joinTo: {
        'stylesheets/app.css': /^app/,
        'stylesheets/vendor.css': /^(?!app\/)/
      }
    }
  },
  npm: {
    styles: {
      purecss: ['build/pure-min.css']
    }
  },
this is my config with brunch "brunch": "^2.8.2",
not sure what version you're using
BTW, that purecss: ['build/pure-min.css'] is to include css, in 2.8.x that's not done by default
not sure about newer versions
John Grimes
@johngrimes
Aug 01 2016 21:48
ok, thanks, i'll see if i can get it all working
Mauro Oviedo
@moviedo
Aug 01 2016 21:48
/^(?!app\/)/ regex is saying include files from all directories excluding app directory
or what ever u call your app dir
@johngrimes also, as a piece of advice and to follow common brunch convention, you should break up ur actually code from your dependencies
joinTo: {
    'app.js': [
      /^node_modules\/react\//,
      /^node_modules\/react-dom\//,
etc...
assuming this works, it would add all ur dependencies with your own js code
John Grimes
@johngrimes
Aug 01 2016 21:51
@moviedo when i use your brunch config, it seems to compile all node_modules* into the vendor bundle
even devDependencies, like selenium, etc. which i don't need in the bundle at all
Mauro Oviedo
@moviedo
Aug 01 2016 21:52
not all, just your declared dependencies in package.json
{
  "dependencies": {
    "lockr": "^0.8.4",
    "purecss": "^0.6.0",
    "vue": "^1.0.25",
    "vue-resource": "^0.8.0"
  },
  "devDependencies": {
    "babel-brunch": "^6.0.4",
    "brunch": "^2.8.2",
    "clean-css-brunch": "^2.0.0",
    "css-brunch": "^2.6.1",
    "javascript-brunch": "^2.0.0",
    "less-brunch": "^2.6.0",
    "uglify-js-brunch": "^2.0.1",
    "vue-brunch": "^1.1.2"
  }
}
should like something like the above
@johngrimes notice how devDependencies has all the brunch build dependencies
herenow
@herenow
Aug 01 2016 21:53
@johngrimes that is strange, it should only include dependencies you require, it should actually analyze your code for requires.
Mauro Oviedo
@moviedo
Aug 01 2016 21:53
also, make sure you're using at least npm 3 and node 4
John Grimes
@johngrimes
Aug 01 2016 21:54
@moviedo yes, but they should be just build dependencies, right? not required in the bundle that gets sent to the client
Mauro Oviedo
@moviedo
Aug 01 2016 21:54
client browser should get vendor.js(i.e. ur lib like jquery) and app.js(your actually app)
John Grimes
@johngrimes
Aug 01 2016 21:55
not brunch
Mauro Oviedo
@moviedo
Aug 01 2016 21:55
vendor.js with the above config i gave an example of only contains jquery and ur other dependency libs
no brunch
u can check the map file that's created to verify that brunch isn't there, which it most definitely is not
map file is created if you didn't override the source map config, and you ran brunch w or brunch b
John Grimes
@johngrimes
Aug 01 2016 22:38
i'll go back and put together a minimal project and see if i can reproduce and post as a gist