Skip to content

Commit 84b9156

Browse files
author
Ścibor Rudnicki
authored
Merge pull request #45 from wwwdevio/master
Fix styleUrls replace.
2 parents fcc41a1 + cc01d96 commit 84b9156

6 files changed

Lines changed: 61 additions & 6 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rollup-plugin-angular",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"description": "Angular2 template and styles inliner",
55
"main": "dist/rollup-plugin-angular.js",
66
"module": "dist/rollup-plugin-angular.esm.js",

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const moduleIdRegex = /moduleId\s*:(.*)/g;
1010
const componentRegex = /@Component\(\s?{([\s\S]*)}\s?\)$|type:\s?Component,\s?args:\s?\[\s?{([\s\S]*)},\s?\]/gm;
1111
const commentRegex = /\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm; // http://www.regextester.com/?fam=96247
1212
const templateUrlRegex = /templateUrl\s*:(.*)/g;
13-
const styleUrlsRegex = /styleUrls\s*:(\s*\[[\s\S]*?\])/g;
13+
const styleUrlsRegex = /styleUrls\s*:(\s*\[[\s\S]*?\])/g; // http://www.regextester.com/?fam=98594
1414
const stringRegex = /(['"`])((?:[^\\]\\\1|.)*?)\1/g;
1515

1616
function insertText(str, dir, preprocessor = res => res, processFilename = false, sourceType = 'ts') {
@@ -76,7 +76,7 @@ export default function angular(options = {}) {
7676
/* replace styles in files generated by ngc */
7777
if (fileExt === 'js') {
7878
replace({
79-
regex: match,
79+
regex: styleUrlsRegex,
8080
replacement: toReplace,
8181
paths: [map],
8282
recursive: true,

test/mochajs/example-component.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,33 @@
22
ExampleComponent.decorators = [
33
{ type: Component, args: [{
44
selector: 'example-component',
5-
templateUrl: `./example-component.html`
5+
templateUrl: `./example-component.html`,
6+
styleUrls: [
7+
'./style.scss',
8+
'./style.scss'
9+
]
610
},] },
711
];
812
913
*/
14+
ExampleComponent.decorators = [
15+
{ type: Component, args: [{
16+
selector: 'example-component',
17+
templateUrl: `./example-component.html`,
18+
styleUrls: [
19+
'./style.scss',
20+
'./style.scss'
21+
]
22+
},] },
23+
];
1024

1125
ExampleComponent.decorators = [
1226
{ type: Component, args: [{
1327
selector: 'example-component',
14-
templateUrl: `./example-component.html`
28+
template: `blaaah`,
29+
style: [
30+
'.test{ }',
31+
'.test_aa {}'
32+
]
1533
},] },
1634
];
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
ExampleComponent.decorators = [
3+
{ type: Component, args: [{
4+
selector: 'example-component',
5+
templateUrl: `./example-component.html`,
6+
styleUrls: [
7+
'./style.scss',
8+
'./style.scss'
9+
]
10+
},] },
11+
];
12+
13+
*/
14+
ExampleComponent.decorators = [
15+
{ type: Component, args: [{
16+
selector: 'example-component',
17+
templateUrl: `./example-component.html`,
18+
styleUrls: [
19+
'./style.scss',
20+
'./style.scss'
21+
]
22+
},] },
23+
];
24+
25+
ExampleComponent.decorators = [
26+
{ type: Component, args: [{
27+
selector: 'example-component',
28+
template: `blaaah`,
29+
style: [
30+
'.test{ }',
31+
'.test_aa {}'
32+
]
33+
},] },
34+
];

test/mochajs/style.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test {
2+
font-family: fantasy;
3+
}

0 commit comments

Comments
 (0)