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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify and improve UXPL development/build process #367
Conversation
@bjacobel, thanks for your PR! By analyzing the annotation information on this pull request, we identified @andy-armstrong and @alisan617 to be potential reviewers |
wpConfigFactory = wpConfig.configFactory, | ||
wpConfigDevServer = wpConfig.devServerConfig; | ||
|
||
/* Builds the pattern library doc into /pldoc/public. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I've never seen multi-line comments like this in our codebase. We either use //
or do a JSDoc-style comment starting with /**
:
Not a big deal if you prefer doing it like this, but just fyi.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably make these JSDoc-like, with a single line summary as the first line. They aren't defining functions per se, but they are defining conceptual blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow @bjacobel. This is an incredibly impressive cleanup. I was convinced that you must have broken preview, but it all looks good to me. Major 馃憤 from me.
@bjacobel my only question is around the "demo" directory. Was that an attempt on Brian to have static samples of our patterns to match production? I think something like that will be valuable to have but maybe we can discuss how to set it up, so it makes sense to everyone. 馃憤 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for speeding this up! 馃敤 馃惡 A bit tangential is that we'll probably need a follow up task to see if we can get it down from 16s (w/ susy modifications?) and also it seems like the speed up has been in improvements through webpack, whereas Insights won't pick up that speed increase because it's using django-libsass--not sure what ecom is doing, but I suspect something similar.
// example demo | ||
demo_src: demoSrc + '/static/images', | ||
demo_src_files: demoSrc + '/static/images/**/*' | ||
pldoc_src_files: pldocSrc + '/static/images/**/*' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that you're just following the previous style here. Why not use camelCase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a +diff because I removed the comma at the end of the line, but yep - we should absolutely be using camelCase for these (or removing them if they're no longer used, which I think these fonts
ones might not be). I'll see what I can do with cleaning this file up 馃憤
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this file ended up being used in like two places. I think it's adding more complexity than it's solving, so it's gone now!
@@ -1,14 +1,9 @@ | |||
'use strict'; | |||
|
|||
var gulp = require('gulp'), | |||
runSequence = require('run-sequence'); | |||
gulpUtil = require('gulp-util'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is gulpUtil
needed?
@@ -1,12 +1,9 @@ | |||
'use strict'; | |||
|
|||
var gulp = require('gulp'), | |||
runSequence = require('run-sequence'); | |||
gulpUtil = require('gulp-util'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question on gulpUtil
.
var branch = gitUtils.currentBranch(), | ||
previewBaseUrl = '/' + branch + '/'; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Total nitty nit: too many spaces.
}); | ||
}); | ||
|
||
/* Builds the pattern library documentation using webpack and serves it with webpack-dev-server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the comment!
alias: { | ||
'edx-pattern-library': path.resolve(__dirname, 'pattern-library'), | ||
'edx-ui-toolkit': path.resolve(__dirname, 'node_modules/edx-ui-toolkit/src') | ||
var devServerConfig = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this could be declared with the other vars.
} | ||
}; | ||
|
||
var configFactory = function(options) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same declaration comment.
siteRoot = process.env.SITE_ROOT !== undefined ? process.env.SITE_ROOT : '/', | ||
publicJavaScriptRoot = 'public/'; | ||
webpack = require('webpack'), | ||
ExtractTextPlugin = require('extract-text-webpack-plugin'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comes from lack of knowledge on my part, and as a result, I would really appreciate some documentation about what this file is doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a bunch more documentation to this file about what all the different settings and paths are doing, let me know what you think.
"development": "gulp build-development", | ||
"lint": "eslint ." | ||
"lint": "eslint .", | ||
"start": "rm -rf pldoc/public && jekyll serve --incremental & webpack-dev-server && fg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Is it possible to move this into a separate script? My general sense is that it's a bit lost in package.json
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"scripts": {}
is a pretty common thing for a package to configure build/development tasks if it's not using another tool like gulp, so I guess the question is does having an npm start
command that does the same thing as $(npm bin)/gulp
add any value?
(I added this because I'm not a huge Gulp fan and I kind of just wanted to prove we didn't need it to do the development workflow... so having proved my point, I'll remove this and just make it an alias on my machine if nobody but me is going to use it 馃槢)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dsjen I removed this, as I decided providing two paths to the same functionality isn't good design.
@bjacobel -- thank you for responding to my feedback! I'm running the page using webpack and it's looking great for the most part. I did run into a problem where the page returns a |
@dsjen, yep, I talk about the 404 for the css file in the "Known Issues" section of the PR. We can look at fixing it in the future, but it'd require creating a new Jekyll theme, I think. |
@bjacobel -- I see! Thanks for the clarification. :) I guess a jira ticket would be nice to capture that so that we can address it later. LGTM! 馃憤 |
Simplify and improve UXPL development/build process
Description
pldoc-styles
, in addition to the time to copy other assets. Now, Webpack can make a production bundle of all the assets (Javascript, fonts, CSS) in around 30 seconds from cold start - but, much better, there is now a development mode that loads up in 19 seconds and caches/recompiles modules based on the contents that are diffed. The new time to recompile a change of the pattern library sass and get it into a new webpack bundle is about 16 seconds, which we know to be the same speed as runningnode-sass
directly on the Pattern Library root, so as we optimize that process (separate ticket to upgrade Susy) that time should drop as well.demo
. It was something Brian Talbot created that hadn't been used or modified since, and in my opinion was superseded by the pattern library documentation but continued to exist alongside (actually, inside) it.webpack-dev-server
to take advantage of hot module reload and Webpack module caching. Now when you save a file, nothing ever needs to touch the filesystem - WDS invokes Webpack, figures out what modules need to be rebuilt based on the dependency graph, triggers a hot module reload on the browser, serves the emitted assets out of memory and proxies all the non-Webpack things through to the Jekyll server.package.json
- some we weren't using at all and some we didn't need anymore.webpack.config.js
- previously it was generated dynamically in one of the gulp tasks. Now it's much more parseable to see what exact settings Webpack is going to get when you start it up, and you can run it from the command line as well.npm start
that does all the same stuff as$(npm bin)/gulp
, even a little faster I think._zappr.yml
- I forgot to remove it when we turned that off.Basically we're making Webpack handle as much of this asset processing/bundling stuff as possible, because it's great at it and we get speed boosts when we stay inside the ecosystem. Gulp's role is reduced because we don't need two asset managers and Webpack is better at it 馃槣
Known issues
pattern-library-doc.css
. This is because there is no separate CSS file built in development (the CSS is completely bundled inside the Javascript, so it can be reloaded with HMR) but it would be too complex to have two different Jekyll templates - one that requests the CSS file for production, and one that doesn't for development. So in development we request the CSS file anyway, knowing it will fail and that the Webpacked CSS will be there inside the JS bundle to style the page anyway.gulp doc-publish
. I'll do it after I get thumbs here, because it will wipe out the existing doc site.Sandbox
http://ux-test.edx.org/bjacobel/fix-css/
Testing Checklist
Non-testing Checklist
Reviewers
If you've been tagged for review, please check your corresponding box once you've given the 馃憤.