Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brunch-config.js boilerplate incorrect #1813

Closed
smpallen99 opened this issue Jul 13, 2016 · 7 comments
Closed

brunch-config.js boilerplate incorrect #1813

smpallen99 opened this issue Jul 13, 2016 · 7 comments

Comments

@smpallen99
Copy link
Contributor

After testing suggestion at the end of #1495 comments and looking at the installer brunch-config.js in master, I suggest the comment be changed to:

      // To use a separate vendor.js bundle, specify two files path
      // http://brunch.io/docs/config#-files-
      // joinTo: {
      //  "js/app.js": /^(web\/static\/js|node_modules)/,
      //  "js/vendor.js": /^(web\/static\/vendor)|(deps)/
      // }

I can reproduce this issue on phoenix 1.2.0. By adding the |node_modules, my phoenix_html.js and phoenix.js files get written.

@josevalim
Copy link
Member

@smpallen99 thank you! Shouldn't we add node_modules instead of deps to vendor.js instead?

@smpallen99
Copy link
Contributor Author

@josevalim Good question. I'm not sure. Actually, my use case is slightly different. I'm adding multiple unconcatenated files from vendor mine looks like:

joinTo: {
  "js/app.js": /^(web\/static\/js|node_modules)/,
  "js/foo.js": ["web/static/vendor/foo.js"],
  "js/bar.js": ["web/static/vendor/bar.js"]
}

The point being, as soon a you move from the default joinTo: "js/app.js" to joinTo: { ... } you need to explicitly add node_modules. Quite frankly, I don't really understand how if finds node_modules with the default.

Short answer is that I'm probably not the right person to answer that.

@josevalim
Copy link
Member

@smpallen99 ok, thank you! I will make the change but I will simply replace deps by node_modules.
❤️ 💚 💙 💛 💜

@smpallen99
Copy link
Contributor Author

I just tried that and get the following js error on loading the page.
Uncaught Error: Cannot find module 'phoenix_html' from 'web/static/js/app.js'.

Here is my brunch-config.js file

exports.config = {
  // See http://brunch.io/#documentation for docs.
  files: {
    javascripts: {
      // joinTo: "js/app.js"
      joinTo: {
       "js/app.js": /^(web\/static\/js)/,
       "js/vendor.js": /^(web\/static\/vendor)|(node_modules)/
      }
    },
    stylesheets: {
      joinTo: "css/app.css",
      order: {
        after: ["web/static/css/app.css"] // concat app.css last
      }
    },
    templates: {
      joinTo: "js/app.js"
    }
  },
  conventions: {
    assets: /^(web\/static\/assets)/
  },
  paths: {
    watched: [
      "web/static",
      "test/static"
    ],
    public: "priv/static"
  },
  plugins: {
    babel: {
      ignore: [/web\/static\/vendor/]
    }
  },
  modules: {
    autoRequire: {
      "js/app.js": ["web/static/js/app"]
    }
  },
  npm: {
    enabled: true
  }
};

@josevalim
Copy link
Member

@smpallen99 thank you, can you please try out this version? https://github.com/phoenixframework/phoenix/blob/master/installer/templates/static/brunch/brunch-config.js

@smpallen99
Copy link
Contributor Author

@josevalim Worked fine with direct copy. Then I replaced joinTo: "js/app.js" with the commented block. No errors, and it generated a vendor.js file built from my web/static/vendor files.

I did not really get the deps part anyway. Nothing to do with the commented description.

I think you have a winner.

@josevalim
Copy link
Member

The deps is from when we loaded Phoenix and phoenix_html from deps.

On Thursday, July 14, 2016, Steve Pallen [email protected] wrote:

@josevalim https://github.com/josevalim Worked fine with direct copy.
Then I replaced joinTo: "js/app.js" with the commented block. No errors,
and it generated a vendor.js file built from my web/static/vendor files.

I did not really get the deps part anyway. Nothing to do with the
commented description.

I think you have a winner.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1813 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAAlbng-kEVQpdn9d9b3q0NBFUBuu3TPks5qVmCtgaJpZM4JL8Vu
.

José Valimwww.plataformatec.com.br
http://www.plataformatec.com.br/Founder and Director of R&D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants