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

Update webpack setup to improve dev and debugging #11

Merged
merged 1 commit into from
Jul 10, 2018

Conversation

dmethvin-gov
Copy link
Contributor

Fixes #5
Fixes #10

  • Auto-open the browser when using npm serve
  • Support a production build
  • Reorganize the webpack settings into dev/prod groups
  • Generate a bundle map for production builds
  • Provide a command to serve out the production files
  • Organize files in the /public folder and ignore built files

Since this is an app (and not a lib) I assume we don't want to commit build artifacts in /public, at least for now. We can always revisit, and we probably will once we settle on some solution for usds/us-forms-system#66 .

For the serving of production files I used npx which will install the http-server package on demand if it isn't present. Alternately I can add it to devDependencies and it can always be installed. I don't have a preference either way.

If this looks good I can add a commit and update the README.md to describe these features.

Copy link
Contributor

@annekainicUSDS annekainicUSDS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good! Just a few questions


module.exports = {
resolve: {
modules: [ 'node_modules' ],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is what resolve defaults to, so you shouldn't need to specify this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of iterations ago I had it automatically looking for modules in us-forms-system subdirectories as well but took it out because I wasn't sure if it was helping or not. I left this in as a reminder but we can take it out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha, in that case if you want to leave it in that's fine!

module.exports = {
resolve: {
modules: [ 'node_modules' ],
extensions: ['.js', '.jsx']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may still be needed in order to resolve the .jsx extension, which I don't believe is included by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i don't think jsx is recognized by default.

const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

module.exports = merge(require('./webpack.common.js'), {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this production webpack config come from somewhere? Curious for the reasoning behind some of the additions here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stats were basically to just show what was available, we can turn it down a bit if the console seems too noisy. The chunks are a work in progress, the size of the app is really too large for a single bundle but I'm not sure what we can do to make that more automatic for someone using the starter app. For the BundleAnalyzerPlugin I am having it create a report in an html file but not automatically displaying it.

@dmethvin-gov
Copy link
Contributor Author

@annekainicUSDS did you want any changes before this lands?

Copy link
Contributor

@annekainicUSDS annekainicUSDS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dmethvin-gov dmethvin-gov merged commit 333548f into usds:master Jul 10, 2018
@dmethvin-gov dmethvin-gov deleted the webpacking branch July 10, 2018 18:45
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

Successfully merging this pull request may close these issues.

2 participants