aliascss 1.3.9 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@ import postcss from 'postcss';
8
8
  import postcssDiscardDuplicates from 'postcss-discard-duplicates';
9
9
  import cssnano from 'cssnano';
10
10
  import chokidar from 'chokidar';
11
+ import sortMediaQueries from 'postcss-sort-media-queries';
11
12
  const init = {
12
13
  classList: [], // hold className for MasterCSS to avoid repeating
13
14
  groups: [],
@@ -18,6 +19,7 @@ const init = {
18
19
  config,
19
20
  '--module': false,
20
21
  rawCSS: '',
22
+ layers: [],
21
23
  customGroupStatement: '',
22
24
  minify: false,
23
25
  globPattern: '', // Use this to check valid new created file to add to watch during watch.on
@@ -48,7 +50,8 @@ export function globalCSSCompiler() {
48
50
  input.forEach((file) => {
49
51
  const [gbContent,] = compileFile(file, config, statementMaker, classList);
50
52
  try {
51
- fs.writeFileSync(init.output, `\n/* Start :-----------ACSS ${path.relative('.', file)}------------------------*/\n${gbContent}
53
+ fs.writeFileSync(init.output, `@layer ${init.layers.join(', ')};
54
+ \n/* Start :-----------ACSS ${path.relative('.', file)}------------------------*/\n${gbContent}
52
55
  \n/* End :-----------ACSS ${path.relative('.', file)}----------------------------*/\n
53
56
  `, { flag: 'a+' });
54
57
  console.log('AliasCSS compiled', path.relative('.', file), 'to main css file :' + init.output);
@@ -156,6 +159,7 @@ export function createCSSFileByFile(file, bool = false) {
156
159
  if (init["--file"]) {
157
160
  try {
158
161
  fs.writeFileSync(file + '.css', content);
162
+ postify(file + '.css', [postcssDiscardDuplicates], init.minify);
159
163
  // console.log(content);
160
164
  console.log('AliasCSS compiled', path.relative('.', file), 'Locally');
161
165
  }
@@ -178,8 +182,11 @@ export function createCSSFileByFile(file, bool = false) {
178
182
  }
179
183
  }
180
184
  }
181
- export function postify(file, plugin, minify = false) {
185
+ export function postify(file, plugin, minify = false, sort = "mobile-first") {
182
186
  const data = fs.readFileSync(file, 'utf-8');
187
+ plugin.push(sortMediaQueries({
188
+ sort
189
+ }));
183
190
  if (fs.existsSync(file)) {
184
191
  if (minify === true)
185
192
  plugin.push(cssnano);
@@ -221,6 +228,13 @@ export function initialize(configFile) {
221
228
  init.input = configFile.input;
222
229
  init.globPattern = configFile.input;
223
230
  }
231
+ // ----------------input-------------------
232
+ if (configFile.hasOwnProperty('layers') && Array.isArray(configFile.layers)) {
233
+ init.layers = configFile.layers;
234
+ }
235
+ else {
236
+ init.layers = config.layers;
237
+ }
224
238
  // ----------------Prefix-------------------
225
239
  if (configFile.hasOwnProperty('prefix')) {
226
240
  init.config.prefix = configFile.prefix;
@@ -268,6 +282,10 @@ export function initialize(configFile) {
268
282
  if (init.config.useExtractorFunction)
269
283
  init.config.matchExtractorFunction = init.config.createExtractorRegex(configFile.extractorFunction);
270
284
  }
285
+ else {
286
+ init.config.useExtractorFunction = true;
287
+ init.config.matchExtractorFunction = init.config.createExtractorRegex('String');
288
+ }
271
289
  // ---------Extend----------------
272
290
  if (configFile.hasOwnProperty('extend') && typeof configFile.extend === 'object') {
273
291
  const filteredObj = {};
@@ -293,6 +311,7 @@ export function initialize(configFile) {
293
311
  else {
294
312
  if (fs.existsSync(init.output))
295
313
  fs.truncateSync(path.resolve(init.output));
314
+ writeStatementToFile(init.output, `@layer ${init.layers.join(', ')};`, 'Initializating @layer,');
296
315
  }
297
316
  // Custom CSS statement
298
317
  if (configFile.hasOwnProperty('statement')) {
@@ -9,7 +9,7 @@ export default function extractClassNamesFromFile(file, config) {
9
9
  const matchCSSModuleFunction = config.useCSSModule ? config.matchCSSModuleFunction : null;
10
10
  const matchRegExp = config.useColon ? config.matchRegExpWithColon : config.matchRegExp;
11
11
  const matchRegExpKeyFrame = config.useColon ? config.matchRegExpWithColonKeyFrame : config.matchRegExpKeyFrame;
12
- const matchRegExpRawCSSStatement = /data-raw-css=(["'])(.*?)\1/;
12
+ const matchRegExpRawCSSStatement = /data-raw-css=(["'])([\s\S]*?)\1/; // data-raw-css=(["'])(.*?)\1/s
13
13
  // 0. data-raw-css=
14
14
  if (data.match(matchRegExpRawCSSStatement)) {
15
15
  const matchesRawCSS = data.match(new RegExp(matchRegExpRawCSSStatement, "g"));
package/lib/prebuild.d.ts CHANGED
@@ -1,125 +1,69 @@
1
1
  declare const _default: {
2
- 'x-btn': {
3
- type: string;
4
- statement: string;
5
- };
6
- 'x-button': {
7
- type: string;
8
- statement: string;
9
- };
10
- 'x-input': {
11
- type: string;
12
- statement: string;
13
- };
14
- 'x-css-reset-normalize': {
15
- type: string;
16
- statement: string;
17
- };
18
- 'x-css-reset': {
19
- type: string;
20
- statement: string;
21
- };
22
- 'x-css-reset-josh': {
23
- type: string;
24
- statement: string;
25
- };
26
- 'x-css-reset-sanitize': {
27
- type: string;
28
- statement: string;
29
- };
30
- 'x-css-reset-preflight': {
31
- type: string;
32
- statement: string;
33
- };
34
- 'x-import-tokens': {
2
+ 'x-absolute-0': {
35
3
  type: string;
36
4
  statement: string;
37
5
  };
38
- 'x-divider-text': {
39
- type: string;
40
- statement: string;
41
- };
42
- 'x-divider': {
43
- type: string;
44
- statement: string;
45
- };
46
- 'x-arrow': {
6
+ 'x-absolute-top': {
47
7
  type: string;
48
8
  statement: string;
49
9
  };
50
- 'x-currency-dollar': {
10
+ 'x-absolute-bottom': {
51
11
  type: string;
52
12
  statement: string;
53
13
  };
54
- 'x-currency-cent': {
14
+ 'x-absolute-right': {
55
15
  type: string;
56
16
  statement: string;
57
17
  };
58
- 'x-currency-pound': {
18
+ 'x-absolute-left': {
59
19
  type: string;
60
20
  statement: string;
61
21
  };
62
- 'x-currency': {
63
- type: string;
64
- statement: string;
65
- };
66
- 'x-currency-yen': {
67
- type: string;
68
- statement: string;
69
- };
70
- 'x-currency-euro-currency': {
71
- type: string;
72
- statement: string;
73
- };
74
- 'x-currency-euro': {
75
- type: string;
76
- statement: string;
77
- };
78
- 'x-currency-rupee': {
22
+ 'x-btn': {
79
23
  type: string;
80
24
  statement: string;
81
25
  };
82
- 'x-symbol-copy-right': {
26
+ 'x-button': {
83
27
  type: string;
84
28
  statement: string;
85
29
  };
86
- 'x-symbol-registered': {
30
+ 'x-input': {
87
31
  type: string;
88
32
  statement: string;
89
33
  };
90
- 'x-symbol-divide': {
34
+ 'x-css-reset-normalize': {
91
35
  type: string;
92
36
  statement: string;
93
37
  };
94
- 'x-symbol-arrow-left': {
38
+ 'x-css-reset': {
95
39
  type: string;
96
40
  statement: string;
97
41
  };
98
- 'x-symbol-arrow-up': {
42
+ 'x-css-reset-josh': {
99
43
  type: string;
100
44
  statement: string;
101
45
  };
102
- 'x-symbol-arrow-right': {
46
+ 'x-css-reset-sanitize': {
103
47
  type: string;
104
48
  statement: string;
105
49
  };
106
- 'x-symbol-arrow-down': {
50
+ 'x-css-reset-preflight': {
107
51
  type: string;
108
52
  statement: string;
109
53
  };
110
- 'x-symbol-arrow-left-right': {
54
+ 'x-import-tokens': {
111
55
  type: string;
112
56
  statement: string;
113
57
  };
114
- 'x-symbol-arrow-down-left': {
58
+ 'x-divider-text': {
115
59
  type: string;
116
60
  statement: string;
117
61
  };
118
- 'x-symbol-square-root': {
62
+ 'x-divider': {
119
63
  type: string;
120
64
  statement: string;
121
65
  };
122
- 'x-symbol-trade-mark': {
66
+ 'x-arrow': {
123
67
  type: string;
124
68
  statement: string;
125
69
  };
@@ -127,11 +71,11 @@ declare const _default: {
127
71
  type: string;
128
72
  statement: string;
129
73
  };
130
- 'x-import-utils-1': {
74
+ 'x-import-utils-classes': {
131
75
  type: string;
132
76
  statement: string;
133
77
  };
134
- 'x-import-vars-dark': {
78
+ 'x-import-utils-ra': {
135
79
  type: string;
136
80
  statement: string;
137
81
  };