brunch-guide icon indicating copy to clipboard operation
brunch-guide copied to clipboard

chapter04-starting-from-scratch.md > Split targets

Open jeffdeville opened this issue 7 years ago • 0 comments

When I copy/paste your brunch-config.js:

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

The build is successful, but I get a js error on the page.

Uncaught Error: Cannot find module 'process' from '/'
    at require (libraries.js:61)
    at jquery.js:1
    at jquery.js:1
require @ libraries.js:61
(anonymous) @ jquery.js:1
(anonymous) @ jquery.js:1

The problem is that this code is added to the generated js:

require.alias("process/browser.js", "process");process = require('process');require.register("___globals___", function(exports, require, module) {

If I remove the code before the globals require, it works.

What I can't figure out, is why I can't change the brunch config to:

module.exports = {
  files: {
    javascripts: {
      joinTo: {
        'libraries.js': "app/jquery.js",
        'app.js': "app/application.js"
      }
    },
    stylesheets: {joinTo: 'app.css'}
  }
}

as a workaround to the problem. I still wind up with the process code, only now the node_module isn't in my app.js or libraries.js.

jeffdeville avatar May 30 '17 13:05 jeffdeville