minista 2.5.0 → 2.6.2

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
@@ -139,6 +139,24 @@ export default defineConfig({
139
139
  },
140
140
  },
141
141
  vite: {}, // https://ja.vitejs.dev/config/
142
+ resolve: {
143
+ alias: [], // { [key: string]: string } | { find: string, replacement: string }[]
144
+ },
145
+ css: {
146
+ modules: {
147
+ cache: true,
148
+ scopeBehaviour: "local",
149
+ globalModulePaths: [],
150
+ generateScopedName: undefined,
151
+ hashPrefix: "",
152
+ localsConvention: "camelCaseOnly",
153
+ }, // https://ja.vitejs.dev/config/#css-modules
154
+ preprocessorOptions: {
155
+ scss: {},
156
+ less: {},
157
+ stylus: {},
158
+ }, // https://ja.vitejs.dev/config/#css-preprocessoroptions
159
+ },
142
160
  markdown: {
143
161
  syntaxHighlighter: "highlight", // "highlight" | "none"
144
162
  highlightOptions: {}, // https://github.com/rehypejs/rehype-highlight#options
@@ -155,26 +173,11 @@ export default defineConfig({
155
173
  max_preserve_newlines: 0,
156
174
  indent_inner_html: true,
157
175
  extra_liners: [],
158
- inline: ["span", "b", "br", "code", "del", "s", "small", "strong", "wbr"],
176
+ inline: ["span", "strong", "b", "small", "del", "s", "code", "br", "wbr"],
159
177
  }, // https://github.com/beautify-web/js-beautify#css--html
160
178
  cssOptions: {}, // https://github.com/beautify-web/js-beautify#css--html
161
179
  jsOptions: {}, // https://github.com/beautify-web/js-beautify#options
162
180
  },
163
- css: {
164
- modules: {
165
- generateScopedName: undefined,
166
- globalModulePaths: [],
167
- hashPrefix: "",
168
- localsConvention: "camelCaseOnly",
169
- scopeBehaviour: "local",
170
- cache: true,
171
- }, // https://ja.vitejs.dev/config/#css-modules
172
- preprocessorOptions: {
173
- scss: {},
174
- less: {},
175
- stylus: {},
176
- }, // https://ja.vitejs.dev/config/#css-preprocessoroptions
177
- },
178
181
  })
179
182
  ```
180
183
 
package/dist/build.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import type { Options as MdxOptions } from "@mdx-js/esbuild";
2
2
  import type { Config as SvgrOptions } from "@svgr/core";
3
3
  import type { InlineConfig } from "vite";
4
- import type { MinistaResolveConfig, RootStaticContent, RootJsxContent, GlobalStaticData, GetGlobalStaticData, PageJsxContent, StaticData, StaticDataItem, GetStaticData, PartialModules, CssOptions } from "./types.js";
4
+ import type { MinistaResolveConfig, RootStaticContent, RootJsxContent, GlobalStaticData, GetGlobalStaticData, PageJsxContent, StaticData, StaticDataItem, GetStaticData, AliasArray, PartialModules, CssOptions } from "./types.js";
5
5
  export declare function buildTempPages(entryPoints: string[], buildOptions: {
6
6
  outBase: string;
7
7
  outDir: string;
8
+ alias: AliasArray;
8
9
  mdxConfig: MdxOptions;
9
10
  svgrOptions: SvgrOptions;
10
11
  cssOptions: CssOptions;
@@ -43,6 +44,7 @@ export declare function buildPartialStringIndex(partialModules: PartialModules,
43
44
  }): Promise<void>;
44
45
  export declare function buildPartialStringBundle(entryPoint: string, buildOptions: {
45
46
  outFile: string;
47
+ alias: AliasArray;
46
48
  mdxConfig: MdxOptions;
47
49
  svgrOptions: SvgrOptions;
48
50
  cssOptions: CssOptions;
package/dist/build.js CHANGED
@@ -40,7 +40,7 @@ import {
40
40
  } from "./esbuild.js";
41
41
  import { renderHtml } from "./render.js";
42
42
  import { slashEnd, reactStylesToString } from "./utils.js";
43
- import { CssModulePlugin } from "./css.js";
43
+ import { cssModulePlugin } from "./css.js";
44
44
  const __filename = url.fileURLToPath(import.meta.url);
45
45
  const __dirname = path.dirname(__filename);
46
46
  const ministaPkgUrl = path.resolve(__dirname + "/../package.json");
@@ -91,14 +91,12 @@ async function buildTempPages(entryPoints, buildOptions) {
91
91
  external: esbuildExternals,
92
92
  loader: esbuildLoaders,
93
93
  plugins: [
94
- CssModulePlugin(buildOptions.cssOptions),
94
+ resolvePlugin({ "react/jsx-runtime": "react/jsx-runtime.js" }),
95
+ cssModulePlugin(buildOptions.cssOptions, buildOptions.alias),
95
96
  mdx(buildOptions.mdxConfig),
96
- resolvePlugin({
97
- "react/jsx-runtime": "react/jsx-runtime.js"
98
- }),
99
97
  svgrPlugin(buildOptions.svgrOptions),
100
- rawPlugin(),
101
- partialHydrationPlugin()
98
+ rawPlugin(buildOptions.alias),
99
+ partialHydrationPlugin(buildOptions.alias)
102
100
  ]
103
101
  }).catch(() => process.exit(1));
104
102
  }
@@ -432,13 +430,11 @@ async function buildPartialStringBundle(entryPoint, buildOptions) {
432
430
  external: esbuildExternals,
433
431
  loader: esbuildLoaders,
434
432
  plugins: [
435
- CssModulePlugin(buildOptions.cssOptions),
433
+ resolvePlugin({ "react/jsx-runtime": "react/jsx-runtime.js" }),
434
+ cssModulePlugin(buildOptions.cssOptions, buildOptions.alias),
436
435
  mdx(buildOptions.mdxConfig),
437
- resolvePlugin({
438
- "react/jsx-runtime": "react/jsx-runtime.js"
439
- }),
440
436
  svgrPlugin(buildOptions.svgrOptions),
441
- rawPlugin()
437
+ rawPlugin(buildOptions.alias)
442
438
  ]
443
439
  }).catch(() => process.exit(1));
444
440
  }
package/dist/config.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import type { MinistaConfig, MinistaUserConfig, MinistaResolveConfig } from "./types.js";
1
+ import type { AliasOptions as ViteAliasOptions } from "vite";
2
+ import type { MinistaConfig, MinistaUserConfig, MinistaResolveConfig, MinistaResolveAliasInput, AliasArray } from "./types.js";
2
3
  export declare const defaultConfig: MinistaConfig;
3
4
  export declare function mergeConfig(userConfig: MinistaUserConfig): Promise<MinistaConfig>;
5
+ export declare function mergeAlias(configAlias: MinistaResolveAliasInput, viteConfigAlias: ViteAliasOptions): Promise<AliasArray>;
4
6
  export declare function resolveConfig(config: MinistaConfig): Promise<MinistaResolveConfig>;
5
7
  export declare function getConfig(userConfig: MinistaUserConfig): Promise<MinistaResolveConfig>;
package/dist/config.js CHANGED
@@ -83,6 +83,24 @@ const defaultConfig = {
83
83
  }
84
84
  },
85
85
  vite: {},
86
+ resolve: {
87
+ alias: []
88
+ },
89
+ css: {
90
+ modules: {
91
+ cache: true,
92
+ scopeBehaviour: "local",
93
+ globalModulePaths: [],
94
+ generateScopedName: void 0,
95
+ hashPrefix: "",
96
+ localsConvention: "camelCaseOnly"
97
+ },
98
+ preprocessorOptions: {
99
+ scss: {},
100
+ less: {},
101
+ stylus: {}
102
+ }
103
+ },
86
104
  markdown: {
87
105
  syntaxHighlighter: "highlight",
88
106
  highlightOptions: {},
@@ -99,25 +117,10 @@ const defaultConfig = {
99
117
  max_preserve_newlines: 0,
100
118
  indent_inner_html: true,
101
119
  extra_liners: [],
102
- inline: ["span", "b", "br", "code", "del", "s", "small", "strong", "wbr"]
120
+ inline: ["span", "strong", "b", "small", "del", "s", "code", "br", "wbr"]
103
121
  },
104
122
  cssOptions: {},
105
123
  jsOptions: {}
106
- },
107
- css: {
108
- modules: {
109
- generateScopedName: void 0,
110
- globalModulePaths: [],
111
- hashPrefix: "",
112
- localsConvention: "camelCaseOnly",
113
- scopeBehaviour: "local",
114
- cache: true
115
- },
116
- preprocessorOptions: {
117
- scss: {},
118
- less: {},
119
- stylus: {}
120
- }
121
124
  }
122
125
  };
123
126
  async function mergeConfig(userConfig) {
@@ -127,8 +130,40 @@ async function mergeConfig(userConfig) {
127
130
  const mergedConfig = customDeepmerge(defaultConfig, userConfig);
128
131
  return mergedConfig;
129
132
  }
133
+ async function mergeAlias(configAlias, viteConfigAlias) {
134
+ const alias = [];
135
+ async function getAlias(input) {
136
+ if (!input) {
137
+ return;
138
+ } else if (Array.isArray(input) && input.length > 0) {
139
+ await Promise.all(input.map(async (item) => {
140
+ const pattern = {
141
+ find: item.find,
142
+ replacement: item.replacement
143
+ };
144
+ return alias.push(pattern);
145
+ }));
146
+ } else if (typeof input === "object") {
147
+ await Promise.all(Object.entries(input).map((item) => {
148
+ const pattern = {
149
+ find: item[0],
150
+ replacement: item[1]
151
+ };
152
+ return alias.push(pattern);
153
+ }));
154
+ }
155
+ }
156
+ await getAlias(configAlias);
157
+ await getAlias(viteConfigAlias);
158
+ return alias;
159
+ }
130
160
  async function resolveConfig(config) {
161
+ var _a;
162
+ const configAlias = config.resolve.alias;
163
+ const viteConfigAlias = ((_a = config.vite.resolve) == null ? void 0 : _a.alias) || {};
164
+ const alias = await mergeAlias(configAlias, viteConfigAlias);
131
165
  const resolvedConfig = __spreadProps(__spreadValues({}, config), {
166
+ alias,
132
167
  rootSrcDir: noSlashEnd(config.root.srcDir),
133
168
  pagesSrcDir: noSlashEnd(config.pages.srcDir),
134
169
  publicOutDir: noSlashEnd(config.out),
@@ -153,6 +188,7 @@ async function getConfig(userConfig) {
153
188
  export {
154
189
  defaultConfig,
155
190
  getConfig,
191
+ mergeAlias,
156
192
  mergeConfig,
157
193
  resolveConfig
158
194
  };
package/dist/css.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { Plugin } from "esbuild";
2
- import type { CssOptions } from "./types.js";
3
- export declare function CssModulePlugin(options: CssOptions): Plugin;
2
+ import type { AliasArray, CssOptions } from "./types.js";
3
+ export declare function cssModulePlugin(options: CssOptions, alias: AliasArray): Plugin;
package/dist/css.js CHANGED
@@ -18,10 +18,10 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import React from "react";
21
- import path from "path";
22
21
  import fs from "fs-extra";
23
22
  import postcss from "postcss";
24
23
  import postcssModules from "postcss-modules";
24
+ import { getEsbuildResolvePath } from "./esbuild.js";
25
25
  var PreprocessLang = /* @__PURE__ */ ((PreprocessLang2) => {
26
26
  PreprocessLang2["less"] = "less";
27
27
  PreprocessLang2["sass"] = "sass";
@@ -110,7 +110,7 @@ async function buildJs(filepath, options) {
110
110
  const classNames = JSON.stringify(cssModulesJSON);
111
111
  return `export default ${classNames};`;
112
112
  }
113
- function CssModulePlugin(options) {
113
+ function cssModulePlugin(options, alias) {
114
114
  const filter = new RegExp(`\\.module${cssLangs}`);
115
115
  return {
116
116
  name: PLUGIN,
@@ -119,19 +119,19 @@ function CssModulePlugin(options) {
119
119
  build.onResolve({ filter, namespace: "file" }, async (args) => {
120
120
  if (!options.modules)
121
121
  return args;
122
- const sourceFullPath = path.resolve(args.resolveDir, args.path);
123
- if (results.has(sourceFullPath))
124
- return results.get(sourceFullPath);
125
- const content = await buildJs(sourceFullPath, options);
122
+ const resolvePath = getEsbuildResolvePath(args, alias);
123
+ if (results.has(resolvePath))
124
+ return results.get(resolvePath);
125
+ const content = await buildJs(resolvePath, options);
126
126
  const result = {
127
- path: args.path,
127
+ path: resolvePath,
128
128
  namespace: PLUGIN,
129
129
  pluginData: {
130
130
  content
131
131
  }
132
132
  };
133
133
  if (options.modules.cache)
134
- results.set(sourceFullPath, result);
134
+ results.set(resolvePath, result);
135
135
  return result;
136
136
  });
137
137
  build.onLoad({ filter, namespace: PLUGIN }, (args) => {
@@ -146,5 +146,5 @@ function CssModulePlugin(options) {
146
146
  };
147
147
  }
148
148
  export {
149
- CssModulePlugin
149
+ cssModulePlugin
150
150
  };
package/dist/esbuild.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import type { Plugin } from "esbuild";
1
+ import type { Plugin, OnResolveArgs } from "esbuild";
2
2
  import type { Config as SvgrOptions } from "@svgr/core";
3
+ import type { AliasObject, AliasArray } from "./types.js";
4
+ export declare function getEsbuildResolvePath(args: OnResolveArgs, alias: AliasArray): string;
3
5
  /*! Fork: esbuild-plugin-resolve | https://github.com/markwylde/esbuild-plugin-resolve */
4
- export declare function resolvePlugin(options: {
5
- [key: string]: string;
6
- }): Plugin;
6
+ export declare function resolvePlugin(alias: AliasObject): Plugin;
7
7
  /*! Fork: esbuild-plugin-svgr | https://github.com/kazijawad/esbuild-plugin-svgr */
8
8
  export declare function svgrPlugin(options: SvgrOptions): Plugin;
9
9
  /*! Fork: esbuild-plugin-resolve | https://github.com/hannoeru/esbuild-plugin-raw */
10
- export declare function rawPlugin(): Plugin;
11
- export declare function partialHydrationPlugin(): Plugin;
10
+ export declare function rawPlugin(alias: AliasArray): Plugin;
11
+ export declare function partialHydrationPlugin(alias: AliasArray): Plugin;
package/dist/esbuild.js CHANGED
@@ -19,8 +19,24 @@ import fs from "fs-extra";
19
19
  import path from "path";
20
20
  import { v4 as uuidv4 } from "uuid";
21
21
  import { systemConfig } from "./system.js";
22
+ function getEsbuildResolvePath(args, alias) {
23
+ const aliasObject = Object.assign({}, ...alias.map((item) => ({
24
+ [item.find]: item.replacement
25
+ })));
26
+ function escapeRegExp(find) {
27
+ return find.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
28
+ }
29
+ const aliasKeys = Object.keys(aliasObject);
30
+ const aliasReg = new RegExp(`^(${aliasKeys.map((x) => escapeRegExp(x)).join("|")})`);
31
+ const aliasPath = args.path.replace(aliasReg, function(match) {
32
+ return aliasObject[match];
33
+ });
34
+ const absolutePath = path.isAbsolute(aliasPath) ? aliasPath : path.join(args.resolveDir, aliasPath);
35
+ const replacedPath = absolutePath.replaceAll("\\", "/");
36
+ return replacedPath;
37
+ }
22
38
  /*! Fork: esbuild-plugin-resolve | https://github.com/markwylde/esbuild-plugin-resolve */
23
- function resolvePlugin(options) {
39
+ function resolvePlugin(alias) {
24
40
  function resolvePluginIntercept(build, moduleName, moduleTarget) {
25
41
  const filter = new RegExp("^" + moduleName + "(?:\\/.*)?$");
26
42
  build.onResolve({ filter }, async (args) => {
@@ -47,8 +63,8 @@ function resolvePlugin(options) {
47
63
  return {
48
64
  name: "esbuild-resolve",
49
65
  setup: (build) => {
50
- for (const moduleName of Object.keys(options)) {
51
- resolvePluginIntercept(build, moduleName, options[moduleName]);
66
+ for (const moduleName of Object.keys(alias)) {
67
+ resolvePluginIntercept(build, moduleName, alias[moduleName]);
52
68
  }
53
69
  }
54
70
  };
@@ -71,13 +87,14 @@ function svgrPlugin(options) {
71
87
  };
72
88
  }
73
89
  /*! Fork: esbuild-plugin-resolve | https://github.com/hannoeru/esbuild-plugin-raw */
74
- function rawPlugin() {
90
+ function rawPlugin(alias) {
75
91
  return {
76
92
  name: "esbuild-raw",
77
93
  setup(build) {
78
94
  build.onResolve({ filter: /\?raw$/ }, (args) => {
95
+ const resolvePath = getEsbuildResolvePath(args, alias);
79
96
  return {
80
- path: path.isAbsolute(args.path) ? args.path : path.join(args.resolveDir, args.path),
97
+ path: resolvePath,
81
98
  namespace: "raw-loader"
82
99
  };
83
100
  });
@@ -90,13 +107,14 @@ function rawPlugin() {
90
107
  }
91
108
  };
92
109
  }
93
- function partialHydrationPlugin() {
110
+ function partialHydrationPlugin(alias) {
94
111
  return {
95
112
  name: "esbuild-partial-hydration",
96
113
  setup(build) {
97
114
  build.onResolve({ filter: /\?ph$/ }, (args) => {
115
+ const resolvePath = getEsbuildResolvePath(args, alias);
98
116
  return {
99
- path: (path.isAbsolute(args.path) ? args.path : path.join(args.resolveDir, args.path)).replaceAll("\\", "/"),
117
+ path: resolvePath,
100
118
  namespace: "partial-hydration-loader"
101
119
  };
102
120
  });
@@ -120,6 +138,7 @@ function partialHydrationPlugin() {
120
138
  };
121
139
  }
122
140
  export {
141
+ getEsbuildResolvePath,
123
142
  partialHydrationPlugin,
124
143
  rawPlugin,
125
144
  resolvePlugin,
package/dist/generate.js CHANGED
@@ -46,6 +46,7 @@ async function generateTempRoot(config, mdxConfig) {
46
46
  await buildTempPages([srcRootFilePaths[0]], {
47
47
  outBase: config.rootSrcDir,
48
48
  outDir: systemConfig.temp.root.outDir,
49
+ alias: config.alias,
49
50
  mdxConfig,
50
51
  svgrOptions: config.assets.svgr.svgrOptions,
51
52
  cssOptions: config.css
@@ -57,6 +58,7 @@ async function generateTempPages(config, mdxConfig) {
57
58
  await buildTempPages(srcPageFilePaths, {
58
59
  outBase: config.pagesSrcDir,
59
60
  outDir: systemConfig.temp.pages.outDir,
61
+ alias: config.alias,
60
62
  mdxConfig,
61
63
  svgrOptions: config.assets.svgr.svgrOptions,
62
64
  cssOptions: config.css
@@ -92,6 +94,7 @@ async function generatePartialHydration(config, mdxConfig, viteConfig) {
92
94
  await buildPartialStringBundle(stringIndex, {
93
95
  outFile: stringBundle,
94
96
  mdxConfig,
97
+ alias: config.alias,
95
98
  svgrOptions: config.assets.svgr.svgrOptions,
96
99
  cssOptions: config.css
97
100
  });
package/dist/path.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import React from "react";
2
2
  import fs from "fs-extra";
3
+ import fg from "fast-glob";
3
4
  import path from "path";
4
- import glob from "tiny-glob";
5
5
  function getFilePath(targetDir, fileName, extension) {
6
6
  const filePath = `${targetDir}/${fileName}.${extension}`;
7
7
  const file = fs.existsSync(path.resolve(filePath)) ? path.resolve(filePath) : "";
8
8
  return file;
9
9
  }
10
10
  async function getFilePaths(targetDir, extensions) {
11
- const strExtension = typeof extensions === "string" ? extensions : extensions.join();
12
- const globPattern = `${targetDir}/**/*.{${strExtension}}`;
13
- const files = await glob(globPattern);
11
+ const strExtension = typeof extensions === "string" ? extensions : extensions.join("|");
12
+ const globPattern = `${targetDir}/**/*.+(${strExtension})`;
13
+ const files = await fg(globPattern, { extglob: true });
14
14
  return files;
15
15
  }
16
16
  async function getSameFilePaths(targetDir, fileName, extensions) {
17
- const strExtension = typeof extensions === "string" ? extensions : extensions.join();
18
- const globPattern = `${targetDir}/${fileName}.{${strExtension}}`;
19
- const files = await glob(globPattern);
17
+ const strExtension = typeof extensions === "string" ? extensions : extensions.join("|");
18
+ const globPattern = `${targetDir}/${fileName}.+(${strExtension})`;
19
+ const files = await fg(globPattern, { extglob: true });
20
20
  return files;
21
21
  }
22
22
  export {
package/dist/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { ExoticComponent } from "react";
2
2
  import type { UserConfig as ViteUserConfig, CorsOptions as ViteCorsOptions } from "vite";
3
3
  import type { Config as SvgrOptions } from "@svgr/core";
4
+ import type { SvgstoreAddOptions } from "@qrac/svgstore";
4
5
  import type { Options as HighlightOptions } from "rehype-highlight";
5
6
  import type { Options as MdxOptions } from "@mdx-js/esbuild";
6
7
  import type { HTMLBeautifyOptions, CSSBeautifyOptions, JSBeautifyOptions } from "js-beautify";
@@ -58,7 +59,7 @@ export declare type MinistaConfig = {
58
59
  srcDir: string;
59
60
  outDir: string;
60
61
  outName: string;
61
- svgstoreOptions: MinistaSvgstoreOptions;
62
+ svgstoreOptions: SvgstoreAddOptions;
62
63
  };
63
64
  download: {
64
65
  useRemote: boolean;
@@ -68,6 +69,10 @@ export declare type MinistaConfig = {
68
69
  };
69
70
  };
70
71
  vite: ViteUserConfig;
72
+ resolve: {
73
+ alias: MinistaResolveAliasInput;
74
+ };
75
+ css: CssOptions;
71
76
  markdown: {
72
77
  syntaxHighlighter: "highlight" | "none";
73
78
  highlightOptions: HighlightOptions;
@@ -80,7 +85,6 @@ export declare type MinistaConfig = {
80
85
  cssOptions: CSSBeautifyOptions;
81
86
  jsOptions: JSBeautifyOptions;
82
87
  };
83
- css: CssOptions;
84
88
  };
85
89
  export declare type MinistaUserConfig = {
86
90
  base?: string;
@@ -134,7 +138,7 @@ export declare type MinistaUserConfig = {
134
138
  srcDir?: string;
135
139
  outDir?: string;
136
140
  outName?: string;
137
- svgstoreOptions?: MinistaSvgstoreOptions;
141
+ svgstoreOptions?: SvgstoreAddOptions;
138
142
  };
139
143
  download?: {
140
144
  useRemote?: boolean;
@@ -144,6 +148,10 @@ export declare type MinistaUserConfig = {
144
148
  };
145
149
  };
146
150
  vite?: ViteUserConfig;
151
+ resolve?: {
152
+ alias?: MinistaResolveAliasInput;
153
+ };
154
+ css?: CssUserOptions;
147
155
  markdown?: {
148
156
  syntaxHighlighter?: "highlight" | "none";
149
157
  highlightOptions?: HighlightOptions;
@@ -156,21 +164,12 @@ export declare type MinistaUserConfig = {
156
164
  cssOptions?: CSSBeautifyOptions;
157
165
  jsOptions?: JSBeautifyOptions;
158
166
  };
159
- css?: CssUserOptions;
160
167
  };
161
- export declare type MinistaSvgstoreOptions = {
162
- cleanDefs?: Boolean | string[];
163
- cleanSymbols?: Boolean | string[];
164
- svgAttrs?: Boolean | {
165
- [key: string]: string;
166
- };
167
- symbolAttrs?: Boolean | {
168
- [key: string]: string;
169
- };
170
- copyAttrs?: Boolean | string[];
171
- renameDefs?: Boolean;
168
+ export declare type MinistaResolveConfig = MinistaConfig & MinistaResolveAliasConfig & MinistaResolvePathConfig;
169
+ export declare type MinistaResolveAliasInput = AliasObject | AliasArray;
170
+ export declare type MinistaResolveAliasConfig = {
171
+ alias: AliasArray;
172
172
  };
173
- export declare type MinistaResolveConfig = MinistaConfig & MinistaResolvePathConfig;
174
173
  export declare type MinistaResolvePathConfig = {
175
174
  rootSrcDir: string;
176
175
  pagesSrcDir: string;
@@ -261,6 +260,13 @@ export declare type StaticDataCache = {
261
260
  key: [StaticDataList];
262
261
  } | {};
263
262
  export declare type GetStaticData = () => Promise<StaticData>;
263
+ export declare type AliasObject = {
264
+ [key: string]: string;
265
+ };
266
+ export declare type AliasArray = {
267
+ find: string;
268
+ replacement: string;
269
+ }[];
264
270
  export declare type PartialModules = {
265
271
  id: string;
266
272
  phId: string;
@@ -275,14 +281,6 @@ export declare type PartialModules = {
275
281
  export declare type PartialString = {
276
282
  [key: string]: string;
277
283
  };
278
- export declare type CSSModulesOptions = {
279
- cache: boolean;
280
- scopeBehaviour: "global" | "local";
281
- globalModulePaths: RegExp[];
282
- generateScopedName: undefined | string | ((name: string, filename: string, css: string) => string);
283
- hashPrefix: string;
284
- localsConvention: "camelCase" | "camelCaseOnly" | "dashes" | "dashesOnly";
285
- };
286
284
  export declare type CssOptions = {
287
285
  modules: CSSModulesOptions | false;
288
286
  preprocessorOptions: {
@@ -299,3 +297,11 @@ export declare type CssUserOptions = {
299
297
  stylus?: Stylus.RenderOptions;
300
298
  };
301
299
  };
300
+ export declare type CSSModulesOptions = {
301
+ cache: boolean;
302
+ scopeBehaviour: "global" | "local";
303
+ globalModulePaths: RegExp[];
304
+ generateScopedName: undefined | string | ((name: string, filename: string, css: string) => string);
305
+ hashPrefix: string;
306
+ localsConvention: "camelCase" | "camelCaseOnly" | "dashes" | "dashesOnly";
307
+ };
package/dist/vite.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import type { UserConfig as ViteConfig, Plugin } from "vite";
2
2
  import type { Config as SvgrOptions } from "@svgr/core";
3
3
  import type { Options as MdxOptions } from "@mdx-js/esbuild";
4
- import type { MinistaResolveConfig, MinistaSvgstoreOptions, MinistaCliDevOptions, MinistaCliPreviewOptions } from "./types.js";
4
+ import type { SvgstoreAddOptions } from "@qrac/svgstore";
5
+ import type { MinistaResolveConfig, MinistaCliDevOptions, MinistaCliPreviewOptions } from "./types.js";
5
6
  export declare function getViteConfig(config: MinistaResolveConfig, mdxConfig: MdxOptions, cliOptions?: MinistaCliDevOptions | MinistaCliPreviewOptions): Promise<ViteConfig>;
6
7
  export declare function resolveEntry(entry: string | string[] | {}): {};
7
8
  export declare function vitePluginMinistaVirtualHtml(): Plugin;
8
9
  /*! Fork: vite-plugin-svgr | https://github.com/pd4d10/vite-plugin-svgr */
9
10
  export declare function vitePluginMinistaSvgr(svgrOptions: SvgrOptions): Plugin;
10
- export declare function vitePluginMinistaSvgSpriteIcons(srcDir: string, options: MinistaSvgstoreOptions | undefined, output: string, tempOutput: string): Plugin;
11
+ export declare function vitePluginMinistaSvgSpriteIcons(srcDir: string, options: SvgstoreAddOptions | undefined, output: string, tempOutput: string): Plugin;
package/dist/vite.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  } from "vite";
13
13
  import react from "@vitejs/plugin-react";
14
14
  import mdx from "@mdx-js/rollup";
15
- import svgstore from "svgstore";
15
+ import svgstore from "@qrac/svgstore";
16
16
  import { systemConfig } from "./system.js";
17
17
  import { getFilePaths } from "./path.js";
18
18
  import { getFilename, getFilenameObject } from "./utils.js";
@@ -92,6 +92,11 @@ async function getViteConfig(config, mdxConfig, cliOptions) {
92
92
  css: config.css
93
93
  });
94
94
  const mergedViteConfig = mergeViteConfig(defaultViteConfig, config.vite);
95
+ if (config.alias.length > 0) {
96
+ await Promise.all(config.alias.map(async (item) => {
97
+ return mergedViteConfig.resolve.alias.push(item);
98
+ }));
99
+ }
95
100
  const svgrPlugin = vitePluginMinistaSvgr(config.assets.svgr.svgrOptions);
96
101
  mergedViteConfig.plugins.push(svgrPlugin);
97
102
  if (config.assets.icons.useSprite) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "minista",
3
3
  "description": "Next.js Like Development with 100% Static Generate",
4
- "version": "2.5.0",
4
+ "version": "2.6.2",
5
5
  "bin": {
6
6
  "minista": "./bin/minista.js"
7
7
  },
@@ -87,18 +87,20 @@
87
87
  "dependencies": {
88
88
  "@mdx-js/esbuild": "^2.1.1",
89
89
  "@mdx-js/rollup": "^2.1.1",
90
+ "@qrac/svgstore": "^3.0.3",
90
91
  "@svgr/core": "^6.2.1",
91
92
  "@vitejs/plugin-react": "^1.3.2",
92
93
  "cac": "^6.7.12",
93
94
  "deepmerge-ts": "^4.0.3",
94
- "esbuild": "^0.14.39",
95
+ "esbuild": "^0.14.42",
96
+ "fast-glob": "^3.2.11",
95
97
  "fs-extra": "^10.1.0",
96
98
  "js-beautify": "^1.14.3",
97
99
  "mime-types": "^2.1.35",
98
- "node-fetch": "^3.2.4",
100
+ "node-fetch": "^3.2.5",
99
101
  "node-html-parser": "^5.3.3",
100
102
  "picocolors": "^1.0.0",
101
- "postcss": "^8.4.13",
103
+ "postcss": "^8.4.14",
102
104
  "postcss-modules": "^4.3.1",
103
105
  "react-helmet": "^6.1.0",
104
106
  "react-router-dom": "^6.3.0",
@@ -107,8 +109,6 @@
107
109
  "remark-gfm": "^3.0.1",
108
110
  "remark-mdx-frontmatter": "^1.1.1",
109
111
  "srcset": "^5.0.0",
110
- "svgstore": "^3.0.1",
111
- "tiny-glob": "^0.2.9",
112
112
  "uuid": "^8.3.2",
113
113
  "vite": "^2.9.9"
114
114
  },
@@ -117,7 +117,7 @@
117
117
  "@types/js-beautify": "^1.13.3",
118
118
  "@types/less": "^3.0.3",
119
119
  "@types/mime-types": "^2.1.1",
120
- "@types/node": "^17.0.34",
120
+ "@types/node": "^17.0.39",
121
121
  "@types/react": "^17.0.45",
122
122
  "@types/react-dom": "^17.0.16",
123
123
  "@types/react-helmet": "^6.1.5",
@@ -126,10 +126,10 @@
126
126
  "less": "^4.1.2",
127
127
  "react": "^17.0.2",
128
128
  "react-dom": "^17.0.2",
129
- "sass": "^1.51.0",
130
- "stylus": "^0.57.0",
131
- "tsup": "^5.12.8",
132
- "typescript": "^4.6.4",
133
- "vitest": "^0.12.6"
129
+ "sass": "^1.52.2",
130
+ "stylus": "^0.58.1",
131
+ "tsup": "^6.0.1",
132
+ "typescript": "^4.7.3",
133
+ "vitest": "^0.13.1"
134
134
  }
135
135
  }