This repository has been archived by the owner on Jun 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 465
Add support for build-time custom bundling #370
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…into jahnp/custom-bundles # Conflicts: # gulp/modules/Plugins.js
…into jahnp/custom-bundles
- Remove custom descriptions for now and use the default comment banner - Add optional "showSize" param & build step to ComponentHelper - Update SASS bundle template to match prop names used in ComponentHelper - Remove LESS bundle template
This reverts commit cf6ed6f.
…ting bundling's call to pass them in. - Update bundle template to account for bundle's changed output path - Add rollup "gulp Bundles" task
Jahnp
changed the title
Jahnp/custom bundles
Add support for build-time custom bundling
Feb 22, 2016
Looks great! |
Nice! The pull request notes can be used in our documentation, and once that's ready we should be good to merge. |
Yep! In fact, in this PR I've included documentation in ghdocs/BUNDLING.md that we can port straight over to the site.The PR notes are pretty much a duplicate of those. |
Perfect, I see it now. We can look at getting this documented on the Fabric site as a future item – for now it's documented along with our current |
// either of an include or of an include's dependency. | ||
let isEntryDependency = isEntryComponent ? cachedManifests.hasOwnProperty(entryName) : false; | ||
|
||
|
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: Extra space
Makes sense! For now, I'll go ahead and merge. Thanks for reviewing! |
Jahnp
added a commit
that referenced
this pull request
Feb 23, 2016
Add support for build-time custom bundling
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Custom Bundling
This pull request adds build-time support for custom "bundles" of Fabric CSS, allowing for the creation of pre-configured subsets of Fabric's styles.
What are bundles and why are they useful?
"Bundles" are simply preconfigured CSS files that are made up of only the pieces of Fabric you specify. This allows you to tailor Fabric to the needs of your app and reduce the impact of including all of Fabric or Fabric's components. The end result is similar to the output of something like
src/sass/Fabric.scss
For example, if your web app or add-in uses only Fabric's Typography styles and Button component, you can configure a bundle that includes only the styles for those elements, and nothing more. However, if a component depends on other components to render properly, those would also be included in the bundle. For example, the HTML for PersonaCard depends on the Persona, OrgChart, and Link components, so a bundle including the PersonaCard would also include the styles for those components.
Usage
Bundling is a build process that depends on Fabric's gulp build tools to work, so first, make sure you've followed the instructions for Building Fabric to set up a local clone of Fabric that is ready for compiling.
Then, configure your bundle in
gulp/Config.js
in thebundlesConfig
property. A bundle is simply a JavaScript object with a name, description, and list of file names to include or exclude from the final output.Exclude vs include
excludes
If you list your files in "excludes", the bundle will be comprised of each .scss file in
src/sass
andsrc/components
except for the files specified. For now, component dependencies are not included when in "exclude" mode.Here's an example "excludes" bundle that excludes the Language Overrides styles:
This will produce a .scss file containing the following:
includes
If instead you use "includes", the bundle will include only the files specified. If the file is a component that has dependencies, like mentioned above, those will also be included. If you aren't sure what a component's dependencies are, look for the "dependencies" property in that component's JSON file in
src/{ComponentName}/{ComponentName}.json
. Note that the build looks for dependencies two children deep, or in other words, dependencies of dependencies.Here's an example "include" bundle that includes only the Button and PersonaCard components:
This will produce the following:
Neither excludes nor includes
If neither "excludes" nor "includes" are specified, the bundle will inlclude all of Fabric's CSS.
gulp Bundles
Then, open a Command Prompt or Terminal window and navigate to the root of your cloned Fabric folder, then run
gulp Bundles
(notice the capitalization of "Bundles"). Each bundle object will build into a full and minified CSS file indist/bundles/{name}
. To see the .scss file that makes up the bundle, checkdist/bundles/{name}/{name}.scss
.