Fetching contributors…
Cannot retrieve contributors at this time
67 lines (48 sloc) 1.37 KB

How to use ngx-md in Angular2 with AoT compilation using ngc and rollup

The compilation process is described on the official Angular2 website here:

1) Install ngx-md

npm install ngx-md --save

2) Edit Angular 2 module

Open the module file where you want to include ngx-md (most probably app.module.ts) and import either specific ngx-md modules by listing them in the import statement and then in the import array of the Angular 2 module

import { NgxMdModule } from 'ngx-md';

   imports: [NgxMdModule.forRoot(), ... ],

3) Edit rollup configuration (rollup-config.js)

You have to use CommonJS rollup plugin, which you should be using anyway due to RxJS. If for some reason not, install it:

npm install rollup-plugin-commonjs --save --dev

Then you have to import the CommonJS plugin, include it in the plugins array and add ngx-md to the list of modules:

import commonjs from 'rollup-plugin-commonjs';

//paths are relative to the execution path
export default {
	plugins: [
			include: [

4) Run compilation the standard way


ngc -p tsconfig-aot.json
rollup -c rollup-config.js