Skip to content

Commit 08bae4d

Browse files
committed
changing to @define and @import-define
1 parent d915826 commit 08bae4d

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

src/postcss-modules-constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let createImportedName = options && options.createImportedName || ((importName/*
1111
export default css => {
1212
/* Find any local let rules and store them*/
1313
let translations = {}
14-
css.eachAtRule(/^-?let$/, atRule => {
14+
css.eachAtRule(/^define$/, atRule => {
1515
let matches
1616
while (matches = matchLet.exec(atRule.params)) {
1717
let [/*match*/, key, value] = matches
@@ -31,7 +31,7 @@ export default css => {
3131

3232
/* Find imports and insert ICSS tmp vars */
3333
let importAliases = []
34-
css.eachAtRule(/^-?import$/, atRule => {
34+
css.eachAtRule(/^import(-define)?$/, atRule => {
3535
let matches = matchImports.exec(atRule.params)
3636
if (matches) {
3737
let [/*match*/, aliases, path] = matches
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
@let small (max-width: 599px);
2-
@let medium (min-width: 600px) and (max-width: 959px);
3-
@let large (min-width: 960px);
1+
@define small (max-width: 599px);
2+
@define medium (min-width: 600px) and (max-width: 959px);
3+
@define large (min-width: 960px);

test/test-cases/constants/colors.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@let primary: #f01;
2-
@let secondary: #2f2;
1+
@define primary: #f01;
2+
@define secondary: #2f2;
33

44
.text-primary {
55
color: primary;

test/test-cases/constants/expected.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
background-color: #2f2;
1616
}
1717

18+
/* Imports without a "from" are just passed through */
19+
@import url('./old-skool.css');
20+
1821
._constants_source__foo {
1922
box-shadow: 0 0 10px #f01;
2023
border-color: #2f2;

test/test-cases/constants/source.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
@let borders: "./borders.css", breakpoints: "./breakpoints.css";
2-
@-import small, medium from breakpoints;
1+
@define borders: "./borders.css", breakpoints: "./breakpoints.css";
2+
@import-define small, medium from breakpoints;
33
@import secondary, primary as blue from "./colors.css";
44

5+
/* Imports without a "from" are just passed through */
6+
@import url('./old-skool.css');
7+
58
.foo {
69
composes: dashed from borders;
710
composes: text-secondary from "./colors.css";

0 commit comments

Comments
 (0)