rollup-plugin-angular
Advanced tools
Comparing version 0.5.1 to 0.5.2
import fs from 'fs'; | ||
import path from 'path'; | ||
import { green } from 'colors'; | ||
import * as colors from 'colors'; | ||
import replace from 'replace'; | ||
@@ -35,8 +34,13 @@ import MagicString from 'magic-string'; | ||
options.preprocessors = options.preprocessors || {}; | ||
options.preprocessors = options.preprocessors || {}; // set default preprocessors to `{}` | ||
options.replace = (typeof options.replace === 'boolean') ? options.replace : true; // set default replace to `true` | ||
// ignore @angular/** modules | ||
options.exclude = options.exclude || []; | ||
if (typeof options.exclude === 'string' || options.exclude instanceof String) { options.exclude = [options.exclude]; } | ||
if (options.exclude.indexOf('node_modules/@angular/**') === -1) { options.exclude.push('node_modules/@angular/**'); } | ||
if (typeof options.exclude === 'string' || options.exclude instanceof String) { | ||
options.exclude = [options.exclude]; | ||
} | ||
if (options.exclude.indexOf('node_modules/@angular/**') === -1) { | ||
options.exclude.push('node_modules/@angular/**'); | ||
} | ||
@@ -49,6 +53,9 @@ var filter = createFilter(options.include, options.exclude); | ||
if (!filter(map)) { return; } | ||
// replace comments in source | ||
source = source.replace(commentRegex, ''); | ||
// use MagicString | ||
var magicString = new MagicString(source); | ||
// get dir from `map` | ||
var dir = path.parse(map).dir; | ||
// get file extension from `map` | ||
var fileExt = map.split('.').pop(); | ||
@@ -68,3 +75,3 @@ | ||
var toReplace = 'template:' + insertText(url, dir, options.preprocessors.template, options.processFilename, options.sourcetype); | ||
if (fileExt === 'js') { | ||
if (fileExt === 'js' && options.replace === true) { | ||
/* replace templateUrl in files generated by ngc */ | ||
@@ -86,3 +93,3 @@ replace({ | ||
/* replace styles in files generated by ngc */ | ||
if (fileExt === 'js') { | ||
if (fileExt === 'js' && options.replace === true) { | ||
replace({ | ||
@@ -89,0 +96,0 @@ regex: styleUrlsRegex, |
@@ -38,8 +38,13 @@ 'use strict'; | ||
options.preprocessors = options.preprocessors || {}; | ||
options.preprocessors = options.preprocessors || {}; // set default preprocessors to `{}` | ||
options.replace = (typeof options.replace === 'boolean') ? options.replace : true; // set default replace to `true` | ||
// ignore @angular/** modules | ||
options.exclude = options.exclude || []; | ||
if (typeof options.exclude === 'string' || options.exclude instanceof String) { options.exclude = [options.exclude]; } | ||
if (options.exclude.indexOf('node_modules/@angular/**') === -1) { options.exclude.push('node_modules/@angular/**'); } | ||
if (typeof options.exclude === 'string' || options.exclude instanceof String) { | ||
options.exclude = [options.exclude]; | ||
} | ||
if (options.exclude.indexOf('node_modules/@angular/**') === -1) { | ||
options.exclude.push('node_modules/@angular/**'); | ||
} | ||
@@ -52,6 +57,9 @@ var filter = rollupPluginutils.createFilter(options.include, options.exclude); | ||
if (!filter(map)) { return; } | ||
// replace comments in source | ||
source = source.replace(commentRegex, ''); | ||
// use MagicString | ||
var magicString = new MagicString(source); | ||
// get dir from `map` | ||
var dir = path.parse(map).dir; | ||
// get file extension from `map` | ||
var fileExt = map.split('.').pop(); | ||
@@ -71,3 +79,3 @@ | ||
var toReplace = 'template:' + insertText(url, dir, options.preprocessors.template, options.processFilename, options.sourcetype); | ||
if (fileExt === 'js') { | ||
if (fileExt === 'js' && options.replace === true) { | ||
/* replace templateUrl in files generated by ngc */ | ||
@@ -89,3 +97,3 @@ replace({ | ||
/* replace styles in files generated by ngc */ | ||
if (fileExt === 'js') { | ||
if (fileExt === 'js' && options.replace === true) { | ||
replace({ | ||
@@ -92,0 +100,0 @@ regex: styleUrlsRegex, |
{ | ||
"name": "rollup-plugin-angular", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "Angular2 template and styles inliner", | ||
@@ -37,15 +37,17 @@ "main": "dist/rollup-plugin-angular.js", | ||
"devDependencies": { | ||
"@angular/common": "^4.3.3", | ||
"@angular/compiler": "^4.3.3", | ||
"@angular/core": "^4.3.3", | ||
"@angular/platform-browser": "^4.3.3", | ||
"@angular/platform-browser-dynamic": "^4.3.3", | ||
"@types/chai": "^4.0.2", | ||
"@types/jasmine": "^2.5.53", | ||
"@angular/common": "^4.3.5", | ||
"@angular/compiler": "^4.3.5", | ||
"@angular/core": "^4.3.5", | ||
"@angular/platform-browser": "^4.3.5", | ||
"@angular/platform-browser-dynamic": "^4.3.5", | ||
"@types/chai": "^4.0.4", | ||
"@types/jasmine": "^2.5.54", | ||
"@types/karma": "^0.13.36", | ||
"@types/mocha": "^2.2.41", | ||
"@types/node": "^8.0.19", | ||
"babel-register": "^6.24.1", | ||
"@types/mocha": "^2.2.42", | ||
"@types/node": "^8.0.24", | ||
"babel-register": "^6.26.0", | ||
"chai": "^4.1.1", | ||
"clean-css": "^4.1.7", | ||
"colors": "^1.1.2", | ||
"html-minifier": "^3.5.3", | ||
"jasmine": "^2.7.0", | ||
@@ -58,16 +60,17 @@ "jasmine-core": "^2.7.0", | ||
"karma-jasmine": "^1.1.0", | ||
"karma-rollup-preprocessor": "^4.0.2", | ||
"karma-rollup-preprocessor": "^4.0.4", | ||
"mocha": "^3.5.0", | ||
"node-sass": "^4.5.3", | ||
"reflect-metadata": "^0.1.10", | ||
"replace": "^0.3.0", | ||
"rollup": "^0.45.2", | ||
"rollup": "^0.48.2", | ||
"rollup-plugin-buble": "^0.15.0", | ||
"rollup-plugin-commonjs": "^8.1.0", | ||
"rollup-plugin-commonjs": "^8.2.0", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
"rollup-plugin-typescript": "^0.8.1", | ||
"rxjs": "^5.4.2", | ||
"rxjs": "^5.4.3", | ||
"ts-node": "^3.3.0", | ||
"typescript": "^2.4.2", | ||
"typescript": "^2.5.1", | ||
"zone.js": "^0.8.16" | ||
} | ||
} |
@@ -76,7 +76,12 @@ [![Build Status](https://travis-ci.org/cebor/rollup-plugin-angular.svg?branch=master)](https://travis-ci.org/cebor/rollup-plugin-angular) | ||
export default { | ||
entry: 'src/main.ts', | ||
format: 'iife', | ||
dest: 'dist/bundle.js', | ||
input: 'src/main.ts', | ||
output: { | ||
format: 'umd', | ||
file: 'dist/bundle.js' | ||
}, | ||
plugins: [ | ||
angular({ | ||
// additional replace `templateUrl` and `stylesUrls` in every `.js` file | ||
// default: true | ||
replace: false, | ||
preprocessors: { | ||
@@ -83,0 +88,0 @@ template: template => minifyHtml(template, htmlminOpts), |
15940
222
99
36