Phoenix: module not found when using app.js & vendor.js in brunch-config

Created on 6 Aug 2015  路  8Comments  路  Source: phoenixframework/phoenix

Starting a clean app with 0.16.1 and changing the brunch-config.js to use both app.js and vendor.js (as shown below) results in an js runtime error in the browser:

Uncaught Error: Cannot find module "deps/phoenix_html/web/static/js/phoenix_html" from "web/static/js/app"

  files: {
    javascripts: {
      // joinTo: 'js/app.js'

      // To use a separate vendor.js bundle, specify two files path
      // https://github.com/brunch/brunch/blob/stable/docs/config.md#files
      joinTo: {
       'js/app.js': /^(web\/static\/js)/,
       'js/vendor.js': /^(web\/static\/vendor)/
     }
      //
      // To change the order of concatenation of files, explictly mention here
      // https://github.com/brunch/brunch/tree/master/docs#concatenation
      // order: {
      //   before: [
      //     'web/static/vendor/js/jquery-2.1.1.js',
      //     'web/static/vendor/js/bootstrap.min.js'
      //   ]
      // }
    },
    stylesheets: {
      joinTo: 'css/app.css'
    },
    templates: {
      joinTo: 'js/app.js'
    }
  }

Most helpful comment

getting same error with brunch 2.7.4

All 8 comments

try: (kill the "^")

joinTo: {
       'js/app.js': /(web\/static\/js)/,

That did it, probably should have noticed that since that's what I've got in my actual app. You want me to send through a pull request to change it?

yes please

I have taken care of this since I was in this space. I tweaked the solution to vendor the phoenix/phoenix_html deps instead of concat them into app.js, which is likely what you want:

      // joinTo: {
      //  'js/app.js': /^(web\/static\/js)/,
      //  'js/vendor.js': /^(web\/static\/vendor)|(deps)/
      // }

The problem is that the dependencies are usually ES6 and I don't think
vendor would compile them? Or would they?

_Jos茅 Valim_
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

The problem is that the dependencies are usually ES6 and I don't think
vendor would compile them? Or would they?

No we should be fine, babel only ignores ignore: [/web\/static\/vendor/] by default.

Ah, I see, perfect, thank you!

getting same error with brunch 2.7.4

Was this page helpful?
0 / 5 - 0 ratings