- Introduction
- Build Commands
- Building the Documentation
- Building the Library
- Component Modules
- Building Individual Components
- Component Debugging
AngularJS Material has a collection of build processes and commands available to deploy distribution files, test components, and more.
These commands are defined within the package.json and two (2) gulp files:
From the project root, install the NPM packages by running
npm installornpm i
The following command line tasks are available:
npm run buildto buildnpm run build:prodto uglify, stripconsole.log, and autoprefix CSSnpm run docs:buildto build the docs intodist/docsnpm run docs:watchto build the library and docs, and rebuild on file changes
npm run lintto run ESLintnpm run test:fastto run smoke testsnpm run test:fullto run all of the unit tests
The AngularJS Material Docs are generated from the source code. The documentation itself uses the AngularJS Material layout, components, and themes.
Our build process uses dgeni, the wonderful documentation generator built by Pete Bacon Darwin.
To view the Docs (locally):
- Build the docs and serve with 'live reload' using
npm run docs:watch - Open Browser to http://localhost:8080
Developers can build the entire AngularJS Material library or individual component modules. The library comprises:
angular-material.js- components, services, and themingangular-material.css|scss- styleslayouts/**.css|scss- default layout stylesheets
To build from the source, simply use:
# Build the library to
#
# - `dist/angular-material.js`
# - `dist/angular-material.css|scss`
# - `dist/layouts`
npm run build
# Build minified assets
#
# - `dist/angular-material.min.js`
# - `dist/angular-material.min.css|scss`
# - `dist/layouts`
npm run build:prodAngularJS Material supports the construction and deployment of individual component builds. Each component is contained within its own module and specifies its own dependencies.
At a minimum, all components have a dependency upon the
coremodule.
For example, the slider component is registered as the material.components.slider module.
To build and deploy assets for each component individually, run:
npm run build:modulesAll component modules are compiled and distributed to:
-- dist
-- modules
-- js
-- core
-- <component folder>
Let's consider the Slider component with its module definition:
/**
* @ngdoc module
* @name material.components.slider
*/
angular.module('material.components.slider', [
'material.core'
]);First build all the component modules.
To use - for example - the Slider component within your own application, simply load the stylesheets and JS from both the slider and the core modules:
-- dist
-- modules
-- js
-- core
-- core.js
-- core.css
-- slider
-- slider.js
-- slider.css
-- slider-default-theme.css
Debugging a demo in the Docs is complicated due the multiple demos loading and initializing. A more practical approach is to open and debug a specific, standalone Component demo.
To open a Component demo outside of the Docs application, just build, deploy and debug that component's demo(s).
For example, to debug the textfield component:
# Watch and build the 'textfield' demos
#
# NOTE: watch-demo will rebuild your component source
# and demos upon each `save`.
# Note: server will livereload demos on port 8080 after updates are
# built (by watch-demo) to the dist/demos/ dir.
#
gulp watch-demo -c textfield serverThe demo build process will deploy a self-contained AngularJS application that runs the specified component's demo(s). E.g.:
dist/demos/textfield/**/*.*dist/demos/tabs/**/*.*- etc.
After running the appropriate watch-demo and server tasks:
- Open browser to http://localhost:8080/dist/demos
- Navigate to
<component>/<demo> - Open Dev Tools and debug...