-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Swap to using webpack #771
Conversation
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.
There are a lot of font files in sphinx_rtd_theme/static/fonts
. Do you need them if they are installed as dependencies?
Given those dependencies won't be shipped in pypi I would say yes? Webpack is actually outputting those files from the dependencies when it runs the build. The number of font files could be reduced by scoping Roboto as well. Couldn't work out how to do that though. |
I can not get the dev server to work unfortunately. |
Happy to have this pull request closed. I thought it was close to parity, but obviously it is still missing too much. |
@SimonBiggs I'd love to see this PR merged, let me know how I can help. Otherwise, I'll probably pull this down and poke it more. I don't have really strong opinions about the stack changes, but webpack replaces a lot of fragile tooling and has shown to be a huge improvement over our gulp build system, and looks like a similar improvement over grunt. I don't have strong opinions on yarn, but the core team doesn't do much JS. Having less JS dependencies is a strong benefit for us, and the reason we're targeting webpack for RTD. If npm can do everything that yarn is doing here, I'm +1 on skipping yarn. |
@agjohnson I'm more than happy to have yarn replaced for npm. There are certainly some benefits, but not enough to force people to step away from what they're used to. I think the best bet would be for you to jump in and poke it, feel free to push to this branch. I can help out if you have questions about decisions I made. |
* Fix issues on paths in build and dev files * Skip yarn to reduce tooling requirements * Minify CSS assets in production * Reduce imports on fonts, hardcode font pieces more. There are problems with the font family names. Roboto mixin brings in everything as `Roboto-Slab-Bold`, which won't match local font name of 'Roboto Slab' * Fix the development instance more: * Add file watching on reST files * Execute build docs command after webpack build Things I'm still not sure about: - [ ] The actual JS output, I haven't vetted this yet - [ ] If woff2 and woff are enough for fonts. The NPM packages are missing other formats
@SimonBiggs Sounds good. I opened up a PR with what I've changed to get going: #781 Some notes about my attempt:
|
https://github.com/nodejs/node-gyp/blob/master/CHANGELOG.md#v400-2019-04-24 Upgrading to version 4.0.0 of
Not sure about that unfortunately. |
Re. Node, version 12.1.0 worked fine after bumping the version of bourbon-neat |
Ah! I looked into this a bit more. It's actually bourbon-neat bringing in an old node-sass, tied to an old node-gyp. Updating to the latest bourbon-neat fixes the python 2/3 issue 👍 But now nothing builds. This is wyrm showing it's age though, all the errors are from changes to Neat. I'm not sure the best thing to do here.
So yeah, ultimately a new bourbon-neat fixes a couple of issues then. Our options, in no particular order of awfulness:
Any thoughts? @jessetan and @Blendify specifically I vote we do a light fork of wyrm into the readthedocs org, fix the Neat issues, install our fork from github here, and worry about the question of maintainership later. For this PR, are we comfortable merging this with Python 2 and Node 10 support? We'd hopefully pretty quickly figure out the issues with Wyrm and support Python 3 and Node 10+. We can block otherwise, but I'm fine accepting Python 2 + Node 10 for a short while. @SimonBiggs if you haven't already, feel free to either merge my branch in here, or give us access to your branch via maintainer permissions: @jessetan it might be good to have you poke the PR i added some fixes on, and see if it solves the issues you hit (minus the obvious issues with Python/Node of course) |
My yarn lock file has all the exact version in it that successfully build with this configuration... |
Already have: However I believe you set your pull request to target the branch on this repo: So I don't have merge permissions here. |
None of these are needed :) The biggest thing I added here I believe is probably my "yarn lock file". Which was hours of dependency iteration finding the right combo that requires no changes from wyrm etc. |
I tried yarn initially and hit installation issues with the requirements. Specifically, bourbon-neat does still pin an old version of node-sass, which brings in node-gyp 3.8, and that is what fails with python 3. This doesn't seem to be a yarn vs npm thing, using python 2 I can install and build with both npm and yarn.
This PR does build assets correctly, however just not with python 3 or node 12 (apparently, i didn't try yet). I'm describing fixing these issues later though, which requires a new version of Neat, which will require changes to Wyrm. |
kk :) |
I took a quick swing at upgrading Neat and it wasn't bad. I have the theme building with the upgrade (not well, but it builds). The rest of the Wyrm tool chain is more broken and not documented -- So I think it's doable without a lot of effort, but I've changed my mind on maintainership. I don't want to be responsible for maintaining this. I think a vendor fork is the best path forward, allowing us to continue with this PR. I have some additions to my PR, I'll merge into this branch after. |
@agjohnson which version of bourbon-neat did you use? I've found that version 1.9 works with Node 12 and python 3. It is the last one in the 1.x branch. From version 2.x the incompatible changes start. |
@jessetan yes! 💯 that does it for me, on a fresh install even. I skipped even testing 1.9, assuming the whole 1.x series has the bad deps. So that, at least for now, puts us in maintainable place. We probably still need to fork Wyrm eventually, but we can kick that can way down the road. |
Okay. Everything is merged here. The last change I'd like some feedback on is: It's proper to make all of these dev dependencies, no? We don't require any of these to run sphinx_rtd_theme, just to work on the theme. I think I'm 👍 on merging after some docs are updated. I'd like to merge translation docs before reworking docs here though. Code review on this PR is not super helpful, it's probably most helpful to check out the branch and try:
|
I believe any dependency which is for something that strictly helps with the development process (like linting for example) they belong in dev dependencies. Anything that is required to make "npm build" work, they belong in dependencies. There is a flag that can be passed to npm install which only installs the dependencies and not dev dependencies. That can be used in the build step of a continuous deployment pipeline to only download what is necessary for the build. |
I think all our dependencies are dev dependencies, since they are used during development. The theme is never installed using npm with dependencies. |
All npm commands work as expected. Three remarks:
|
Also, npm says:
Which would be no packages. I'll leave these dependencies in dev dependencies for now.
Good point. I'll see if there is a way to make the dev server avoid this.
👍 I actually made this change, but reverted it.
That should be easy enough to add and seems like it would be useful. |
Tests are all breaking because of a change introduced I believe in #405, where setup.py is importing the sphinx_rtd_theme package to get the Edit: Bah, nevermind. I have doc updates due here anyways. I'll do it the right way. |
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.
npm install
npm run build
npm run start
This ran fine for me although I have the following notes:
npm run build
did show changes in the repo (sphinx_rtd_theme/static/css/theme.css
) after running.npm run start
ran successfully for me although I had a few issues with making changes/rebuilding/live-reloading. It would sometimes refresh to a directory listing page when sphinx is rebuilding. Likewise, I had the same "Cannot GET /" issue as @jessetan. Both of these were fairly minor, IMO.- I tested making a change while running
npm run start
and the change was visible after reloading.
@@ -55,7 +53,7 @@ def run(self): | |||
|
|||
setup( | |||
name='sphinx_rtd_theme', | |||
version=__version__, | |||
version='0.4.3.dev0', |
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 see that you're addressing this in another PR. You can also consider reading the version from package.json
. Unfortunately, that file can't also read the version from the Python theme module (and the theme module can't read from package.json
). I've seen a couple approaches here from reading from package.json
to having a separate file with just the version (eg. sphinx_rtd_theme/version.py
) to parsing the text of sphinx_rtd_theme/__init__.py
instead of importing it. I don't have a particularly strong opinion although any of them seem preferable to hardcoding it.
Overall, this is a huge improvement over what was there before, IMO. Thanks a lot for the contribution and persistence @SimonBiggs. |
Merging! 🚀 Thanks everyone! And thanks again @SimonBiggs for getting this rolling! |
My pleasure :) thank you for the improvements on it, and for the maintenance of this theme :) |
This is pull request is a follow up to the following issue:
#757
The live reload server is run with
yarn start
, the production build is built withyarn build
.