Skip to content

Commit 756c7a8

Browse files
IanVSromainmenke
authored andcommitted
Allow parsing .cjs files as javascript (csstools/postcss-env-function#13)
1 parent 6c5942f commit 756c7a8

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

plugins/postcss-env-function/.tape.js

+8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ module.exports = {
6161
expect: 'basic.import.expect.css',
6262
result: 'basic.import.result.css'
6363
},
64+
'basic:import-cjs': {
65+
message: 'supports { importFrom: "test/import-variables.cjs" } usage',
66+
options: {
67+
importFrom: 'test/import-variables.cjs'
68+
},
69+
expect: 'basic.import.expect.css',
70+
result: 'basic.import.result.css'
71+
},
6472
'basic:import-js-from': {
6573
message: 'supports { importFrom: { from: "test/import-variables.js" } } usage',
6674
options: {

plugins/postcss-env-function/src/lib/import-from.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default function importEnvironmentVariablesFromSources(sources) {
7373
}).reduce(async (environmentVariables, source) => {
7474
const { type, from } = await source;
7575

76-
if (type === 'js') {
76+
if (type === 'js' || type === 'cjs') {
7777
return Object.assign(environmentVariables, await importEnvironmentVariablesFromJSFile(from));
7878
}
7979

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
environmentVariables: {
3+
'--some-custom-padding': '20px',
4+
'--another-custom-width': '600px'
5+
}
6+
};

0 commit comments

Comments
 (0)