@md-plugins/vite-examples-plugin 0.1.0-alpha.2 → 0.1.0-alpha.5

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
@@ -30,13 +30,17 @@ pnpm add @md-plugins/vite-examples-plugin
30
30
 
31
31
  To use the `viteExamplesPlugin`, configure it in your Vite project:
32
32
 
33
- ```js
33
+ ```typescript
34
34
  import { defineConfig } from 'vite'
35
35
  import vue from '@vitejs/plugin-vue'
36
- import { viteExamplesPlugin } from '@md-plugin/vite-examples-plugin'
36
+ import { viteExamplesPlugin, viteManualChunks } from 'vite-examples-plugin'
37
37
 
38
- export default defineConfig({
39
- plugins: [vue(), viteExamplesPlugin('/absolute/path/to/examples')],
38
+ export default defineConfig(({ mode }) => {
39
+ const isProduction = mode === 'production'
40
+
41
+ return {
42
+ plugins: [vue(), viteExamplesPlugin(isProduction, '/absolute/path/to/examples')],
43
+ }
40
44
  })
41
45
  ```
42
46
 
@@ -74,7 +78,7 @@ export default defineConfig((ctx) => {
74
78
  ```js
75
79
  build: {
76
80
  vitePlugins: [
77
- viteExamplesPlugin(ctx.appPaths.srcDir + '/examples'),
81
+ viteExamplesPlugin(ctx.isProd, ctx.appPaths.srcDir + '/examples'),
78
82
  // ...
79
83
  ],
80
84
  },
@@ -91,9 +95,7 @@ import { viteExamplesPlugin, viteManualChunks } from '@md-plugins/vite-examples-
91
95
  build: {
92
96
  extendViteConf(viteConf, { isClient }) {
93
97
  if (ctx.prod && isClient) {
94
- if (!viteConf.build) {
95
- viteConf.build = {}
96
- }
98
+ viteConf.build = viteConf.build || {}
97
99
  viteConf.build.chunkSizeWarningLimit = 650
98
100
  viteConf.build.rollupOptions = {
99
101
  output: { manualChunks: viteManualChunks },
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin } from 'vite';
1
+ import { Plugin } from '/home/jeff/git/github/jeff/md-plugins/node_modules/.pnpm/vite@6.0.7_@types+node@22.10.5_jiti@2.4.2_sass-embedded@1.83.0_terser@5.37.0/node_modules/vite/dist/node/index.d.ts';
2
2
 
3
3
  /**
4
4
  * Creates a Vite plugin for handling Markdown examples.
@@ -7,10 +7,18 @@ import { Plugin } from 'vite';
7
7
  * that creates the actual Vite plugin. The returned plugin resolves and loads
8
8
  * example code based on the production or development environment.
9
9
  *
10
+ * @param isProd - A boolean indicating whether the Vite build is in production mode.
11
+ * This parameter determines whether the plugin will use the `prodLoad` or `devLoad` function for loading example code.
12
+ *
10
13
  * @param path - The path to the directory containing the example files.
11
14
  * This path will be used as the target folder for resolving examples.
15
+ * The `targetFolder` variable is set to this value before creating the Vite plugin.
12
16
  *
13
17
  * @returns A function that creates a Vite plugin.
18
+ * The returned function takes a boolean parameter `isProd` and returns a Vite plugin object.
19
+ * The plugin object has a `name`, `enforce`, `resolveId`, and `load` property.
20
+ * The `resolveId` property resolves module IDs starting with "examples:" and returns a resolved ID.
21
+ * The `load` property loads example code based on the production or development environment.
14
22
  */
15
23
  declare function viteExamplesPlugin(isProd: boolean, path: string): Plugin;
16
24
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin } from 'vite';
1
+ import { Plugin } from '/home/jeff/git/github/jeff/md-plugins/node_modules/.pnpm/vite@6.0.7_@types+node@22.10.5_jiti@2.4.2_sass-embedded@1.83.0_terser@5.37.0/node_modules/vite/dist/node/index.d.ts';
2
2
 
3
3
  /**
4
4
  * Creates a Vite plugin for handling Markdown examples.
@@ -7,10 +7,18 @@ import { Plugin } from 'vite';
7
7
  * that creates the actual Vite plugin. The returned plugin resolves and loads
8
8
  * example code based on the production or development environment.
9
9
  *
10
+ * @param isProd - A boolean indicating whether the Vite build is in production mode.
11
+ * This parameter determines whether the plugin will use the `prodLoad` or `devLoad` function for loading example code.
12
+ *
10
13
  * @param path - The path to the directory containing the example files.
11
14
  * This path will be used as the target folder for resolving examples.
15
+ * The `targetFolder` variable is set to this value before creating the Vite plugin.
12
16
  *
13
17
  * @returns A function that creates a Vite plugin.
18
+ * The returned function takes a boolean parameter `isProd` and returns a Vite plugin object.
19
+ * The plugin object has a `name`, `enforce`, `resolveId`, and `load` property.
20
+ * The `resolveId` property resolves module IDs starting with "examples:" and returns a resolved ID.
21
+ * The `load` property loads example code based on the production or development environment.
14
22
  */
15
23
  declare function viteExamplesPlugin(isProd: boolean, path: string): Plugin;
16
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@md-plugins/vite-examples-plugin",
3
- "version": "0.1.0-alpha.2",
3
+ "version": "0.1.0-alpha.5",
4
4
  "description": "A Vite plugin for @md-plugins for handling imported examples in markdown files.",
5
5
  "keywords": [
6
6
  "markdown-it",
@@ -37,9 +37,9 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "dependencies": {
40
+ "devDependencies": {
41
41
  "tinyglobby": "^0.2.10",
42
- "vite": "^6.0.6"
42
+ "vite": "^6.0.7"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "unbuild",