b13-rocket 0.8.7 → 0.8.9

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.
package/README.md CHANGED
@@ -79,6 +79,9 @@ export const config = definePackageConfig({
79
79
  input: '', // entry js file
80
80
  output: '', // output directory
81
81
  root: '', // project root
82
+ postcss: {
83
+ sortMediaQueries: true, // default: true
84
+ },
82
85
  viteConfig: {
83
86
  // Override Vite config for this package
84
87
  resolve: {
@@ -91,6 +94,18 @@ export const config = definePackageConfig({
91
94
 
92
95
  ```
93
96
 
97
+ Disable media query sorting for one package:
98
+
99
+ ```js
100
+ export const config = definePackageConfig({
101
+ name: 'labels',
102
+ // ...
103
+ postcss: {
104
+ sortMediaQueries: false,
105
+ },
106
+ });
107
+ ```
108
+
94
109
  ---
95
110
 
96
111
  ## Extract CSS
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export function definePackageConfig({ name = '', input = '', output = '', root = '', viteConfig = {}}) {
1
+ export function definePackageConfig({ name = '', input = '', output = '', root = '', viteConfig = {}, postcss = {} }) {
2
2
 
3
3
  return {
4
4
  name,
@@ -6,5 +6,6 @@ export function definePackageConfig({ name = '', input = '', output = '', root =
6
6
  output,
7
7
  root,
8
8
  viteConfig,
9
+ postcss,
9
10
  };
10
11
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "b13-rocket",
3
3
  "description": "FE CLI build tool",
4
- "version": "0.8.7",
4
+ "version": "0.8.9",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=v16.13.0",
package/src/build.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { build as viteBuild, defineConfig, mergeConfig , createServer, loadEnv} from 'vite';
2
- import { defaultViteConfig } from './vite/vite.config.js';
2
+ import { createDefaultViteConfig } from './vite/vite.config.js';
3
3
  import fs from 'node:fs';
4
4
 
5
5
  // post process manifest json
@@ -35,6 +35,9 @@ const postProcessManifest = (manifestPath = '') => {
35
35
  }
36
36
 
37
37
  async function vite(config = {}, sharedViteConfig = {}, enableServer = false) {
38
+ const defaultViteConfig = createDefaultViteConfig({
39
+ sortMediaQueries: config?.postcss?.sortMediaQueries !== false,
40
+ });
38
41
 
39
42
  let viteConfig = mergeConfig(
40
43
  defaultViteConfig,
@@ -11,56 +11,65 @@ import browserslist from 'browserslist';
11
11
  const mode = 'production';
12
12
  const browserslistConfig = browserslist.loadConfig({ path: process.cwd() }) ?? browserslist.defaults
13
13
 
14
- export const defaultViteConfig = defineConfig({
15
- mode,
16
- publicDir: false,
17
- base: './',
18
- build: {
19
- manifest: true,
20
- target: 'es2020',
21
- rollupOptions: {
22
- output: {
23
- entryFileNames: '[name].js',
24
- assetFileNames: ((assetInfo) => {
25
- // don't add filename hash for external css files starting 'external-'
26
- const regex = /external-.*?\.(?:css|scss)/
27
- if (regex.test(assetInfo.originalFileName)) {
28
- return '[name][extname]';
29
- }
30
- return 'assets/[name].[hash][extname]';
31
- }),
32
- manualChunks: (chunkPath) => {
33
- const fileName = path.basename(chunkPath);
34
- // add extra chunck for all css files starting with 'external-'
35
- if (fileName.startsWith('external-') && fileName.match(/\.(css|scss)$/)) {
36
- return fileName;
37
- }
38
- return chunkPath.split('/').reverse()[chunkPath.split('/').reverse().indexOf('node_modules') - 1];
14
+ export function createDefaultViteConfig({ sortMediaQueries = true } = {}) {
15
+ return defineConfig({
16
+ mode,
17
+ publicDir: false,
18
+ base: './',
19
+ build: {
20
+ manifest: true,
21
+ target: 'es2020',
22
+ rollupOptions: {
23
+ output: {
24
+ entryFileNames: '[name].js',
25
+ assetFileNames: ((assetInfo) => {
26
+ // don't add filename hash for external css files starting 'external-'
27
+ const regex = /external-.*?\.(?:css|scss)/
28
+ if (regex.test(assetInfo.originalFileName)) {
29
+ return '[name][extname]';
30
+ }
31
+ return 'assets/[name].[hash][extname]';
32
+ }),
33
+ manualChunks: (chunkPath) => {
34
+ const fileName = path.basename(chunkPath);
35
+ // add extra chunck for all css files starting with 'external-'
36
+ if (fileName.startsWith('external-') && fileName.match(/\.(css|scss)$/)) {
37
+ return fileName;
38
+ }
39
+ return chunkPath.split('/').reverse()[chunkPath.split('/').reverse().indexOf('node_modules') - 1];
40
+ },
39
41
  },
40
42
  },
41
43
  },
42
- },
43
- plugins: [
44
- svgLoader({
45
- defaultImport: 'url',
46
- }),
47
- ViteImageOptimizer(),
48
- ],
49
- css: {
50
- devSourcemap: true,
51
- postcss: {
52
- plugins: [
53
- nested(),
54
- postcssPresetEnv({ browsers: browserslistConfig.join(' and ') }),
55
- postcssSortMediaQueries(),
56
- autoprefixer({}),
57
- ],
58
- },
59
- preprocessorOptions: {
60
- scss: {
61
- api: 'modern',
62
- additionalData: `$mode: ${mode};`,
44
+ plugins: [
45
+ svgLoader({
46
+ defaultImport: 'url',
47
+ }),
48
+ ViteImageOptimizer(),
49
+ ],
50
+ css: {
51
+ devSourcemap: true,
52
+ postcss: {
53
+ plugins: [
54
+ nested(),
55
+ postcssPresetEnv({
56
+ browsers: browserslistConfig.join(' and '),
57
+ features: {
58
+ 'logical-properties-and-values': false
59
+ }
60
+ }),
61
+ sortMediaQueries ? postcssSortMediaQueries() : null,
62
+ autoprefixer({}),
63
+ ].filter(Boolean),
64
+ },
65
+ preprocessorOptions: {
66
+ scss: {
67
+ api: 'modern',
68
+ additionalData: `$mode: ${mode};`,
69
+ },
63
70
  },
64
71
  },
65
- },
66
- });
72
+ });
73
+ }
74
+
75
+ export const defaultViteConfig = createDefaultViteConfig();