@best-shot/preset-mini 0.0.0 → 0.2.0

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.
Files changed (3) hide show
  1. package/README.md +11 -0
  2. package/index.mjs +15 -10
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -17,3 +17,14 @@ A `best-shot` preset for mini program project.
17
17
  ```bash
18
18
  npm install @best-shot/preset-mini --save-dev
19
19
  ```
20
+
21
+ ## Usage
22
+
23
+ ```mjs
24
+ // example: .best-shot/config.mjs
25
+ export default {
26
+ presets: ['babel', 'style', 'mini'],
27
+ output: { path: 'dist' },
28
+ appConfig: true
29
+ };
30
+ ```
package/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url';
2
2
 
3
3
  import { getAllPages, readYAML } from './helper.mjs';
4
4
 
5
- export function apply() {
5
+ export function apply({ config: { appConfig } }) {
6
6
  return (chain) => {
7
7
  chain.module
8
8
  .rule('vue')
@@ -14,17 +14,19 @@ export function apply() {
14
14
 
15
15
  const context = chain.get('context');
16
16
 
17
- const io = readYAML('app.yaml', context);
18
- const allPages = getAllPages(io);
17
+ if (appConfig) {
18
+ const io = readYAML('app.yaml', context);
19
+ const allPages = getAllPages(io);
19
20
 
20
- chain
21
- .entry('app')
22
- .add('./app.js')
23
- .add('./app.css')
24
- .add('./app.yaml?to-url');
21
+ chain
22
+ .entry('app')
23
+ .add('./app.js')
24
+ .add('./app.css')
25
+ .add('./app.yaml?to-url');
25
26
 
26
- for (const page of allPages) {
27
- chain.entry(page).add(`./${page}.vue`);
27
+ for (const page of allPages) {
28
+ chain.entry(page).add(`./${page}.vue`);
29
+ }
28
30
  }
29
31
  };
30
32
  }
@@ -32,6 +34,9 @@ export function apply() {
32
34
  export const name = 'preset-mini';
33
35
 
34
36
  export const schema = {
37
+ appConfig: {
38
+ default: false,
39
+ },
35
40
  target: {
36
41
  default: 'es2024',
37
42
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@best-shot/preset-mini",
3
- "version": "0.0.0",
3
+ "version": "0.2.0",
4
4
  "description": "A `best-shot` preset for mini program project",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -29,12 +29,12 @@
29
29
  "type": "module",
30
30
  "dependencies": {
31
31
  "yaml": "^2.4.5",
32
- "@best-shot/sfc-split-loader": "~0.2.0"
32
+ "@best-shot/sfc-split-loader": "~0.3.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@best-shot/core": "~0.9.17",
36
- "@best-shot/preset-babel": "~0.14.8",
37
- "@best-shot/preset-style": "~0.12.14"
36
+ "@best-shot/preset-style": "~0.12.14",
37
+ "@best-shot/preset-babel": "~0.14.9"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">=20.6.0 || ^18.19.0"