Skip to content

Commit 50b9b88

Browse files
committed
fix(autoprefix): handle true value as autoprefixCss config
1 parent 544639c commit 50b9b88

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

src/compiler/style/test/optimize-css.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ describe('optimizeCss', () => {
2727
expect(diagnostics).toHaveLength(1);
2828
});
2929

30+
it('handles autoprefixerCss true config', async () => {
31+
config.autoprefixCss = true;
32+
config.minifyCss = true;
33+
const styleText = `/* css */ body { color: #ff0000; }`;
34+
const output = await optimizeCss(config, compilerCtx, diagnostics, styleText, null, true);
35+
36+
expect(diagnostics).toHaveLength(0);
37+
expect(output).toBe(`body{color:red}`);
38+
});
39+
3040
it('discard-comments', async () => {
3141
config.minifyCss = true;
3242
const styleText = `/* css */ body { color: #ff0000; }`;

src/declarations/config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ import * as d from '.';
44
* https://stenciljs.com/docs/config/
55
*/
66
export interface StencilConfig {
7+
/**
8+
* By default, Stencil will use the appropriate config to automatically prefix css. For example,
9+
* developers can write modern and standard css properties, such as "transform", and Stencil
10+
* will automatically add in the prefixed version, such as "-webkit-transform". To disable
11+
* autoprefixing css, set this value to `false`.
12+
*/
13+
autoprefixCss?: boolean | any;
14+
715
/**
816
* By default, Stencil will statically analyze the application and generate a component graph of
917
* how all the components are interconnected.
@@ -104,7 +112,6 @@ export interface StencilConfig {
104112
srcDir?: string;
105113

106114
assetVersioning?: ConfigAssetVersioning;
107-
autoprefixCss?: boolean | any;
108115
buildEs5?: boolean;
109116
buildEsm?: boolean;
110117
buildScoped?: boolean;

src/sys/node/node-sys-main.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ export class NodeSystem implements d.StencilSystem {
111111
};
112112
}
113113

114-
async autoprefixCss(input: string, opts: any): Promise<string> {
115-
return this.sysWorker.run('autoprefixCss', [input, opts]);
116-
}
117-
118114
async copy(copyTasks: d.CopyTask[]): Promise<d.CopyResults> {
119115
return this.sysWorker.run('copy', [copyTasks], { isLongRunningTask: true });
120116
}

src/sys/node/optimize-css-worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export async function optimizeCssWorker(inputOpts: d.OptimizeCssInput) {
4949

5050

5151
export function addAutoprefixer(inputOpts: d.OptimizeCssInput) {
52-
const autoprefixerOpts = inputOpts.autoprefixer || DEFAULT_AUTOPREFIX_LEGACY;
52+
const autoprefixerOpts: any = (inputOpts.autoprefixer && typeof inputOpts.autoprefixer === 'object') || DEFAULT_AUTOPREFIX_LEGACY;
5353

5454
return autoprefixer(autoprefixerOpts);
5555
}

0 commit comments

Comments
 (0)