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

90 basic webpack #334

Merged
merged 45 commits into from
Mar 27, 2019
Merged

90 basic webpack #334

merged 45 commits into from
Mar 27, 2019

Conversation

JBCSU
Copy link
Collaborator

@JBCSU JBCSU commented Mar 12, 2019

READY FOR REVIEW

Have at it, folks.

Summary

  • replace the grunt build system with webpack

Needed By (Date)

  • 3/27/2019 (5.0 release)

Urgency

  • moderate - site builders' work will be easier when this is finished

Noteworthy changes

  • npm has been upgraded to the latest version supported by nvm, 10.15.1. Make sure you have this version installed via nvm: nvm install 10.15.1 .
  • Almost all npm packages have been removed. Many new ones have been added. All are now at their latest version.
  • Generated css and js now lives in core/dist/css and core/dist/js, respectively. (They used to live in core/css and core/js.)
  • Images referred to in .scss are now inlined in the generated.css as data.
  • Images referred to in .twig files are (mostly) merely placeholders, and therefore, IMO, are not technically part of core. I have placed those images in a new root directory, img-placeholders. All images in that directory are copied to styleguide/img whenever you (re-)build the styleguide. Templates that refer to placeholders now refer to /img/... (absolute vs. relative url). (The one exception is the search icon in the search component. I propose the search icon be implemented via scss so it can be inlined / bundled with core.)

Known Issues

  • CSS source maps aren't generating. No idea why. I'll keep trying.
  • linters are not yet configured. That should be relatively quick, and I can probably get it in this PR.
  • I have not (yet) provided an equivalent to browserSync. npm run watch will rebuild the .css and / or .js when corresponding source files change; however, you have to manually refresh your browser to load them. I believe I can implement this with webpack's hot module replacement, but that will take some time to configure properly. I would like to address that in separate PR.
  • There is no watch on .twig or .json files, so you need to manually run npm run styleguide and refresh your browser when those files change. I don't think there's a way to implement this purely with npm (webpack is not involved in kss generation). Do we need to retain grunt for this?
  • I have not (yet) provided an equivalent to grunt deploy. I haven't found an npm equivalent for grunt-deploy-site. Maybe we need to retain grunt for that one task???
  • There are some codeclimate complaints. I believe most of these are issues we agreed to accept when we merged the nav branch, but we can discuss.

Steps to Test

⚠️
WARNING: This PR changes (almost) every build tool we use, including the version of node / npm. It also changes where output files are stored (from core to core/dist). It is challenging to switch between this branch and any other branch in the repo. You may want to clone this branch to a separate local repo on your machine to avoid the overhead of switching back and forth.
⚠️

One time only

  • If you don't already have nvm's latest version of node / npm, do nvm install 10.15.1.

If you're testing in a pre-existing local repo:

  1. rm -rf node_modules to wipe out all tools used in the grunt-based build env
  2. npm cache clean --force to really wipe out everything
  3. rm -rf styleguide to delete the assets generated by webpack (just for completeness)

Once you're In a clean repo (either a new one, or one you cleaned following the preceding steps):

  1. nvm use to use the version of npm specified in .nvmrc, i.e. 10.15.1
  2. npm install to install the webpack tools

To build decanter and the styleguide:

  1. Build the assets and the styleguide
    1. npm run build to generate the dev version of css and js, and build the styleguide OR
    2. npm run dist to generate the prod version of css and js, and build the styleguide
  2. You can also just build just the styleguide without rebuilding assets:
    1. npm run styleguide to generate the styleguide NB this does not build the css

If you decided to do this in the same local repo you use for other decanter development and you want to switch to a different branch

Before you switch to a different branch you should:

  1. rm -rf node_modules to wipe out all tools used in this branch
  2. npm cache clean --force to really wipe out everything
  3. rm -rf styleguide to delete the assets generated by webpack (just for completeness)
  4. check out the branch you want to switch to
  5. nvm use to use the version of npm specified in .nvmrc, i.e. 9.10.1
  6. npm install to re-install the grunt tools

Affected Projects or Products

  • Final assets have moved from core/css/ and core/js/ to core/dist/css and core/dist/js. All products built on Decanter that load the pre-built assets will need to look in the new directories.

Associated Issues and/or People

See Also

JBCSU added 19 commits February 5, 2019 10:22
* master:
  Add linear gradient background mixin (#304)
  Tweaking modular-spacing mixin to be more user friendly (#309)
  120 Skiplinks (#303)
  72 main nav (#264)
  Update _input.scss (#301)
  Update README.md (#302)
  298-change "sticky-footer" mixin to target <footer> selector  (#299)
  Set base font size for each breakpoint (#295)
  doc: add period (#294)
  151 global footer tweaks (#293)
  Small bugfix for mobile. (#291)
  282: Fix modular-spacing mixins and variables (#290)

# Conflicts:
#	core/js/decanter.js - moved code into core/js/components/main-nav/main-nav.js
* master:
  Reorganize files for CTA so it's consistent with other components (#345)
  Update main-nav.twig (#331)
  get rid of ID (#342)
  5 Lines Lockup + Variants (#289)
  Update _alert--info.scss (#330)

# Conflicts: all resolved using "mine"
#	core/dist/css/decanter.css
#	package-lock.json
#	package.json
…is branch (will delete when the PR is approved)
@JBCSU JBCSU added this to the Version 5.0.0 milestone Mar 19, 2019
JBCSU added 3 commits March 19, 2019 18:16
* master:
  Cut down on media queries generated by @modular-spacing (#343)
  Main Nav Light on Dark Background Color Variant (#344)

# Conflicts:
#	core/dist/css/decanter.css - resolved using master's, then rebuilt with webpack
@JBCSU
Copy link
Collaborator Author

JBCSU commented Mar 20, 2019

Oh. Looks like we used grunt to build the styleguide's custom css. Oy. 🙃

webpack.config.js Outdated Show resolved Hide resolved
sherakama and others added 9 commits March 22, 2019 14:57
* src & dist directory
* Working watch on all JS, SASS, Twig, and JSON
* Adds working map files
* Restores some Grunt tasks and replaces what now has npm scripts with a grunt run npm script instead.
* Moved assets to kss-assets where they should have been in the first place
* Changed up the npm scripts so they don't call everything all the time. Added a new dev function to do that.
* Compiles the KSS theme as well.
* master:
  Replace KSS nav with main-nav component (#348)
  Refactor card component using placeholder and match Figma design (#332)

# Conflicts:
#	core/scss/components/card/_card.scss - resolved using master's
JBCSU added 5 commits March 26, 2019 16:24
Merge branch '90-basic-webpack' of github.com:SU-SWS/decanter into 90-basic-webpack

* '90-basic-webpack' of github.com:SU-SWS/decanter:
  Replace watch plugin with new watch plugin.
  fixup.
Merge branch '90-basic-webpack' of github.com:SU-SWS/decanter into 90-basic-webpack

* '90-basic-webpack' of github.com:SU-SWS/decanter:
  Replace watch plugin with new watch plugin.
  fixup.
* master:
  remove reference to search icon in main-nav twig and json; add documentation to Noto Sans (#359)
  Refactor site-search so the icon can be turned into inline CSS by Webpack (#350)
get directories from package.json;
the styleguide doesn't need assets.json
use filemanager-webpack-plugin to:
- delete all generated assets (including css) prior to building
- copy generated assets to the styleguide after building
@JBCSU
Copy link
Collaborator Author

JBCSU commented Mar 27, 2019

@sherakama I've committed all the changes we discussed today:

  • reorganized the files into core/src and core/dist
  • reorganized the webpack plugins, inspired by your 90-fixup, which resolved the problem with the clean plugin
  • got devMode working (triggered off the name of the npm script: 'dist' = production, anything else is dev)
  • replaced the clean plugin with the file manager plugin, and used it to
    • clean generated assets before building
    • copy generated assets to the styleguide after building (there's a comment explaining why I did it the way I did)
  • merged master to get the search icon inlined as data

Thanks again for your help on this PR in general, and today in particular. I look forward to discussing tomorrow.

JBCSU and others added 7 commits March 26, 2019 20:10
* Fixup! paths.

* kss/builder/decanter/kss-assets/css/

* Added the webpack dev server.

* Added copying of the templates directory from src to dist.

* Removed templates from dist.

* suppress webpack warning about mode not being set

* Asset handling.

* eslint needs to look in core/src
@sherakama sherakama merged commit 2d35518 into master Mar 27, 2019
@sherakama sherakama deleted the 90-basic-webpack branch March 27, 2019 19:38
yvonnetangsu added a commit that referenced this pull request Jun 11, 2019
* master: (44 commits)
  Set up color maps for Decanter and refactor main nav colors to refer to color maps (#420)
  Move PR template (#416)
  Fix skiplink target so it doesn't take up space and cause overflow (#415)
  Release 5.0.1 (#417)
  Fix CSS grid gaps not displaying on Edge issue and other minor grid related issues (#413)
  More link fixup (#388)
  forgot to rebuild .js after final lint fixes (#387)
  add openNav, closeNav, openSubnav, closeSubnav events (#379)
  Fix main nav color variants and work with new linting rules (#380)
  add favicon to style guide (#377)
  Adjust linters. (#370)
  update readme.md to match Scott's intro on homepage.md (#371)
  Update README.md (#369)
  move the images we need for the styleguide's homepage into kss-assets (#368)
  Update README.md (#367)
  Update UPGRADE.md (#363)
  package.locl.json file is back (#366)
  Added more to changelog (#364)
  Update homepage.md (#362)
  90 basic webpack (#334)
  ...

# Conflicts:
#	core/scss/components/index.scss
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.

3 participants