Skip to content

Commit 6519745

Browse files
filipesilvahansl
authored andcommitted
fix(@angular-devkit/build-angular): support inline javascript in less
Based on angular/devkit#866 Fix #10430
1 parent c0f61dc commit 6519745

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/styles.ts

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
220220
loader: 'less-loader',
221221
options: {
222222
sourceMap: cssSourceMap,
223+
javascriptEnabled: true,
223224
...lessPathOptions,
224225
}
225226
}]

packages/angular_devkit/build_angular/test/browser/styles_spec_large.ts

+18
Original file line numberDiff line numberDiff line change
@@ -529,4 +529,22 @@ describe('Browser Builder styles', () => {
529529
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
530530
).toPromise().then(done, done.fail);
531531
});
532+
533+
it(`supports inline javascript in less`, (done) => {
534+
const overrides = { styles: [`src/styles.less`] };
535+
host.writeMultipleFiles({
536+
'src/styles.less': `
537+
.myFunction() {
538+
@functions: ~\`(function () {
539+
return '';
540+
})()\`;
541+
}
542+
.myFunction();
543+
`,
544+
});
545+
546+
runTargetSpec(host, browserTargetSpec, overrides).pipe(
547+
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
548+
).toPromise().then(done, done.fail);
549+
});
532550
});

0 commit comments

Comments
 (0)