docs/guides/BUILD.md
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 install or npm iThe following command line tasks are available:
npm run build to buildnpm run build:prod to uglify, strip console.log, and autoprefix CSSnpm run docs:build to build the docs into dist/docsnpm run docs:watch to build the library and docs, and rebuild on file changes<a separator></a>
npm run lint to run ESLintnpm run test:fast to run smoke testsnpm run test:full to run all of the unit testsThe 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):
npm run docs:watchDevelopers 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 stylesheetsTo 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:prod
##<a name="comp"></a> Component Modules
AngularJS 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:modules
All 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 server
The 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/**/*.*After running the appropriate watch-demo and server tasks:
<component>/<demo>