Skip to content

Commit a3824fa

Browse files
committed
fix: go ahead with normal css processing if config isn't found
1 parent 78ac640 commit a3824fa

File tree

2 files changed

+11
-217
lines changed

2 files changed

+11
-217
lines changed

lib/transformers/cssTransformer.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ import cssnanoLite from '../html/css-nano.mjs'
55

66
export const cssTransformer = () => ({
77
transform: async (code, file) => {
8-
const { plugins, options } = await postcssrc()
8+
const { plugins, options } = await postcssrc().catch(err=>{
9+
if(String(err).includes("No PostCSS Config found")){
10+
return {
11+
plugins:[],
12+
options:{}
13+
}
14+
}
15+
throw err
16+
})
917
const result = await postcss(
1018
...plugins,
1119
...cssnanoLite(),
@@ -14,6 +22,7 @@ export const cssTransformer = () => ({
1422
...options,
1523
from: file,
1624
})
25+
console.log({result})
1726
return result.css
1827
},
1928
ext: '.css',

test/__snapshots__/basic.test.js.snap

Lines changed: 1 addition & 216 deletions
Original file line numberDiff line numberDiff line change
@@ -2,222 +2,7 @@
22

33
exports[`basic > matches transformed css 1`] = `
44
{
5-
"content": "/*! modern-normalize v3.0.1 | MIT License | https://github.com/sindresorhus/modern-normalize */
6-
7-
/*
8-
Document
9-
========
10-
*/
11-
12-
/**
13-
Use a better box model (opinionated).
14-
*/
15-
16-
*,
17-
::before,
18-
::after {
19-
box-sizing: border-box;
20-
}
21-
22-
html {
23-
/* Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3) */
24-
font-family:
25-
system-ui,
26-
'Segoe UI',
27-
Roboto,
28-
Helvetica,
29-
Arial,
30-
sans-serif,
31-
'Apple Color Emoji',
32-
'Segoe UI Emoji';
33-
line-height: 1.15; /* 1. Correct the line height in all browsers. */
34-
-webkit-text-size-adjust: 100%; /* 2. Prevent adjustments of font size after orientation changes in iOS. */
35-
-moz-tab-size: 4;
36-
-o-tab-size: 4;
37-
tab-size: 4; /* 3. Use a more readable tab size (opinionated). */
38-
}
39-
40-
/*
41-
Sections
42-
========
43-
*/
44-
45-
body {
46-
margin: 0; /* Remove the margin in all browsers. */
47-
}
48-
49-
/*
50-
Text-level semantics
51-
====================
52-
*/
53-
54-
/**
55-
Add the correct font weight in Chrome and Safari.
56-
*/
57-
58-
b,
59-
strong {
60-
font-weight: bolder;
61-
}
62-
63-
/**
64-
1. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
65-
2. Correct the odd 'em' font sizing in all browsers.
66-
*/
67-
68-
code,
69-
kbd,
70-
samp,
71-
pre {
72-
font-family:
73-
ui-monospace,
74-
SFMono-Regular,
75-
Consolas,
76-
'Liberation Mono',
77-
Menlo,
78-
monospace; /* 1 */
79-
font-size: 1em; /* 2 */
80-
}
81-
82-
/**
83-
Add the correct font size in all browsers.
84-
*/
85-
86-
small {
87-
font-size: 80%;
88-
}
89-
90-
/**
91-
Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
92-
*/
93-
94-
sub,
95-
sup {
96-
font-size: 75%;
97-
line-height: 0;
98-
position: relative;
99-
vertical-align: baseline;
100-
}
101-
102-
sub {
103-
bottom: -0.25em;
104-
}
105-
106-
sup {
107-
top: -0.5em;
108-
}
109-
110-
/*
111-
Tabular data
112-
============
113-
*/
114-
115-
/**
116-
Correct table border color inheritance in Chrome and Safari. (https://issues.chromium.org/issues/40615503, https://bugs.webkit.org/show_bug.cgi?id=195016)
117-
*/
118-
119-
table {
120-
border-color: currentcolor;
121-
}
122-
123-
/*
124-
Forms
125-
=====
126-
*/
127-
128-
/**
129-
1. Change the font styles in all browsers.
130-
2. Remove the margin in Firefox and Safari.
131-
*/
132-
133-
button,
134-
input,
135-
optgroup,
136-
select,
137-
textarea {
138-
font-family: inherit; /* 1 */
139-
font-size: 100%; /* 1 */
140-
line-height: 1.15; /* 1 */
141-
margin: 0; /* 2 */
142-
}
143-
144-
/**
145-
Correct the inability to style clickable types in iOS and Safari.
146-
*/
147-
148-
button,
149-
[type='button'],
150-
[type='reset'],
151-
[type='submit'] {
152-
-webkit-appearance: button;
153-
}
154-
155-
/**
156-
Remove the padding so developers are not caught out when they zero out 'fieldset' elements in all browsers.
157-
*/
158-
159-
legend {
160-
padding: 0;
161-
}
162-
163-
/**
164-
Add the correct vertical alignment in Chrome and Firefox.
165-
*/
166-
167-
progress {
168-
vertical-align: baseline;
169-
}
170-
171-
/**
172-
Correct the cursor style of increment and decrement buttons in Safari.
173-
*/
174-
175-
::-webkit-inner-spin-button,
176-
::-webkit-outer-spin-button {
177-
height: auto;
178-
}
179-
180-
/**
181-
1. Correct the odd appearance in Chrome and Safari.
182-
2. Correct the outline style in Safari.
183-
*/
184-
185-
[type='search'] {
186-
-webkit-appearance: textfield; /* 1 */
187-
outline-offset: -2px; /* 2 */
188-
}
189-
190-
/**
191-
Remove the inner padding in Chrome and Safari on macOS.
192-
*/
193-
194-
::-webkit-search-decoration {
195-
-webkit-appearance: none;
196-
}
197-
198-
/**
199-
1. Correct the inability to style clickable types in iOS and Safari.
200-
2. Change font properties to 'inherit' in Safari.
201-
*/
202-
203-
::-webkit-file-upload-button {
204-
-webkit-appearance: button; /* 1 */
205-
font: inherit; /* 2 */
206-
}
207-
208-
/*
209-
Interactive
210-
===========
211-
*/
212-
213-
/*
214-
Add the correct display in Chrome and Safari.
215-
*/
216-
217-
summary {
218-
display: list-item;
219-
}
220-
",
5+
"content": "/*! modern-normalize v3.0.1 | MIT License | https://github.com/sindresorhus/modern-normalize */*,:after,:before{box-sizing:border-box}html{font-family:system-ui,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;line-height:1.15;-webkit-text-size-adjust:100%;tab-size:4}body{margin:0}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-color:currentcolor}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}legend{padding:0}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}",
2216
"dist": "",
2227
"source": "/Users/sid/lab/codename-public/test/samples/basic/main.css",
2238
}

0 commit comments

Comments
 (0)