Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Webpack should compile different JS files #847

Closed
paganotoni opened this issue Jan 12, 2018 · 10 comments
Closed

Webpack should compile different JS files #847

paganotoni opened this issue Jan 12, 2018 · 10 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@paganotoni
Copy link
Member

Under some situations as a developer you want to have different JS for different pages in your application, this can be for multiple reasons, the reasons I've faced are:

  • You don't want to load unneeded libraries on every page
  • You don't want to expose some JS functionality in public pages
  • You want to have your JS logic separated

As a solution Buffalo could have webpack compile every file on the /assets/js folder into its fingerprinted version inside /public/assets and in order to avoid partial files, we could exclude files that start with an underscore or another pattern we decide.

Changes to make this possible would be done in the generated webpack.config.js.

@paganotoni paganotoni added the enhancement New feature or request label Jan 12, 2018
@paganotoni paganotoni self-assigned this Jan 12, 2018
@markbates markbates added this to the 0.11.0 milestone Jan 12, 2018
@markbates
Copy link
Member

Love it. I would use _file.js for partials to match plush and sass.

@paganotoni
Copy link
Member Author

Great! it seems that for our sass files it's the same story, we're only generating application.css, should we include in this issue doing the same with sass (i can see almost the same reasons to separate your style).

@markbates
Copy link
Member

I assumed you meant both. :) Definitely!

@stanislas-m
Copy link
Member

@paganotoni
Copy link
Member Author

@stanislas-m #849

@markbates markbates reopened this Jan 17, 2018
@markbates
Copy link
Member

@paganotoni I started working on a new application and found out that this is causing some problems.

Everything works fine, but when I change, say application.js it cleans out the old application.hash.js file, but never rebuilds it and updates the manifest.json. This results in a lot of these types of errors:

could not find assets/application.7cf2e05554e16f6c5e3c.js

The only way to fix the problem is to restart buffalo dev.

This either needs to be fixed before we release 0.11.0 or it needs to be reverted.

@paganotoni
Copy link
Member Author

@markbates when are we planning to release 0.11.0 ? I want to commit to have this in 0.11.0

@markbates
Copy link
Member

right now February 12th

@paganotoni
Copy link
Member Author

In that case let’s have it in 0.11.0

@paganotoni
Copy link
Member Author

paganotoni commented Jan 17, 2018

@markbates this issue seems not to be caused by this particular feature, anyways I'm working on it, I changed my webpack configuration to be the old one and it still happens when you change a file and save it multiple times quickly, it kind of loses contact with the assets folder and webpack stops recompiling.

There is another issue with the fonts that I've added in #821.

I continued looking into the config and seems the culprit is the CleanWebpackPlugin configuration we're using, by disabling the watch property this seems to be fixed, I'm preparing a PR for this and #821 soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants