vite-intlayer 4.0.0 → 4.0.3
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 +41 -236
- package/dist/cjs/intlayerPlugin.cjs.map +1 -1
- package/dist/esm/intlayerPlugin.mjs.map +1 -1
- package/dist/types/intlayerPlugin.d.ts +1 -1
- package/package.json +10 -35
package/README.md
CHANGED
|
@@ -1,275 +1,80 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<a href="https://www.npmjs.com/package/
|
|
2
|
+
<a href="https://www.npmjs.com/package/vite-intlayer">
|
|
3
3
|
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/572ae9c9acafb74307b81530c1931a8e98990aef/docs/assets/logo.png" width="500" alt="intlayer" />
|
|
4
4
|
</a>
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
7
|
<div align="center">
|
|
8
|
-
<a href="https://www.npmjs.com/package/
|
|
9
|
-
<img alt="npm" src="https://img.shields.io/npm/v/
|
|
8
|
+
<a href="https://www.npmjs.com/package/vite-intlayer">
|
|
9
|
+
<img alt="npm" src="https://img.shields.io/npm/v/vite-intlayer.svg?labelColor=49516F&color=8994BC" />
|
|
10
10
|
</a>
|
|
11
|
-
<a href="https://npmjs.org/package/
|
|
12
|
-
<img alt="downloads" src="https://badgen.net/npm/dm/
|
|
11
|
+
<a href="https://npmjs.org/package/vite-intlayer">
|
|
12
|
+
<img alt="downloads" src="https://badgen.net/npm/dm/vite-intlayer?labelColor=49516F&color=8994BC" />
|
|
13
13
|
</a>
|
|
14
|
-
<a href="https://npmjs.org/package/
|
|
15
|
-
<img alt="types included" src="https://badgen.net/npm/types/
|
|
14
|
+
<a href="https://npmjs.org/package/vite-intlayer">
|
|
15
|
+
<img alt="types included" src="https://badgen.net/npm/types/vite-intlayer?labelColor=49516F&color=8994BC"
|
|
16
16
|
/>
|
|
17
17
|
</a>
|
|
18
18
|
</div>
|
|
19
19
|
|
|
20
|
-
#
|
|
20
|
+
# vite-intlayer: Internationalize (i18n) an Vite application
|
|
21
21
|
|
|
22
|
-
**Intlayer** is
|
|
22
|
+
**Intlayer** is a suite of packages designed specifically for JavaScript developers. It is compatible with frameworks like React, React, and Express.js.
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
.
|
|
28
|
-
├── Component1
|
|
29
|
-
│ ├── index.content.ts
|
|
30
|
-
│ └── index.tsx
|
|
31
|
-
└── Component2
|
|
32
|
-
├── index.content.ts
|
|
33
|
-
└── index.tsx
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
```tsx
|
|
37
|
-
// ./Component1/index.content.ts
|
|
38
|
-
|
|
39
|
-
import { type DeclarationContent, t } from "intlayer";
|
|
40
|
-
|
|
41
|
-
const component1Content = {
|
|
42
|
-
key: "component1",
|
|
43
|
-
content: {
|
|
44
|
-
myTranslatedContent: t({
|
|
45
|
-
en: "Hello World",
|
|
46
|
-
fr: "Bonjour le monde",
|
|
47
|
-
es: "Hola Mundo",
|
|
48
|
-
}),
|
|
49
|
-
},
|
|
50
|
-
} satisfies DeclarationContent;
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
```tsx
|
|
54
|
-
// ./Component1/index.tsx
|
|
55
|
-
|
|
56
|
-
import { useIntlayer } from "react-intlayer";
|
|
57
|
-
|
|
58
|
-
export const Component1 = () => {
|
|
59
|
-
const { myTranslatedContent } = useIntlayer("component1");
|
|
60
|
-
|
|
61
|
-
return <span>{myTranslatedContent}</span>;
|
|
62
|
-
};
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Why Choose Intlayer?
|
|
66
|
-
|
|
67
|
-
- **JavaScript-Powered Content Management**: Harness the flexibility of JavaScript to define and manage your content efficiently.
|
|
68
|
-
- **Type-Safe Environment**: Leverage TypeScript to ensure all your content definitions are precise and error-free.
|
|
69
|
-
- **Integrated Content Files**: Keep your translations close to their respective components, enhancing maintainability and clarity.
|
|
70
|
-
- **Simplified Setup**: Get up and running quickly with minimal configuration, especially optimized for Next.js projects.
|
|
71
|
-
- **Server Component Support**: Perfectly suited for Next.js server components, ensuring smooth server-side rendering.
|
|
72
|
-
- **Enhanced Routing**: Full support for Next.js app routing, adapting seamlessly to complex application structures.
|
|
73
|
-
|
|
74
|
-
# Getting Started with Intlayer and React Create App
|
|
75
|
-
|
|
76
|
-
Setting up Intlayer in a Create React App application is straightforward:
|
|
77
|
-
|
|
78
|
-
## Step 1: Install Dependencies
|
|
79
|
-
|
|
80
|
-
Install the necessary packages using npm:
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
npm install intlayer react-intlayer
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
yarn add intlayer react-intlayer
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
pnpm add intlayer react-intlayer
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Step 2: Configuration of your project
|
|
95
|
-
|
|
96
|
-
Create a config file to configure the languages of your application:
|
|
24
|
+
**The `vite-intlayer` package** allows you to internationalize your Vite application. It includes the Vite plugin to set the configuration through environment variables into the [Vite bundler](https://vitejs.dev/guide/why.html#why-bundle-for-production). It also provides middleware to detect the user's preferred locale, and redirect the user to the appropriate URL as specified in the [configuration](https://github.com/aymericzip/intlayer/blob/main/docs/en/configuration.md).
|
|
97
25
|
|
|
98
|
-
|
|
99
|
-
// intlayer.config.ts
|
|
26
|
+
## Why Internationalize Your Vite Application?
|
|
100
27
|
|
|
101
|
-
|
|
28
|
+
Internationalizing your Vite application is essential for serving a global audience effectively. It allows your application to deliver content and messages in the preferred language of each user. This capability enhances user experience and broadens your application's reach by making it more accessible and relevant to people from different linguistic backgrounds.
|
|
102
29
|
|
|
103
|
-
|
|
104
|
-
internationalization: {
|
|
105
|
-
locales: [
|
|
106
|
-
Locales.ENGLISH,
|
|
107
|
-
Locales.FRENCH,
|
|
108
|
-
Locales.SPANISH,
|
|
109
|
-
// Your other locales
|
|
110
|
-
],
|
|
111
|
-
defaultLocale: Locales.ENGLISH,
|
|
112
|
-
},
|
|
113
|
-
};
|
|
30
|
+
## Configuration
|
|
114
31
|
|
|
115
|
-
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
To see all available parameters, refer to the [configuration documentation here](https://github.com/aymericzip/intlayer/blob/main/docs/en/configuration.md).
|
|
32
|
+
The `vite-intlayer` package works seamlessly with the [`vite-intlayer` package](https://github.com/aymericzip/intlayer/blob/main/docs/en/packages/vite-intlayer/index.md), and the [`intlayer` package](https://github.com/aymericzip/intlayer/blob/main/docs/en/packages/intlayer/index.md). Have a look at the relevant documentation for more information.
|
|
119
33
|
|
|
120
|
-
##
|
|
34
|
+
## Installation
|
|
121
35
|
|
|
122
|
-
|
|
36
|
+
Install the necessary package using your preferred package manager:
|
|
123
37
|
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
"build": "react-intlayer build",
|
|
127
|
-
"start": "react-intlayer start",
|
|
128
|
-
"transpile": "intlayer build"
|
|
129
|
-
},
|
|
38
|
+
```bash packageManager="npm"
|
|
39
|
+
npm install vite-intlayer
|
|
130
40
|
```
|
|
131
41
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
## Step 4: Declare Your Content
|
|
135
|
-
|
|
136
|
-
Create and manage your content dictionaries:
|
|
137
|
-
|
|
138
|
-
```tsx
|
|
139
|
-
// src/app.content.tsx
|
|
140
|
-
import { t, type DeclarationContent } from "intlayer";
|
|
141
|
-
import { type ReactNode } from "react";
|
|
142
|
-
|
|
143
|
-
const appContent = {
|
|
144
|
-
key: "app",
|
|
145
|
-
content: {
|
|
146
|
-
getStarted: t<ReactNode>({
|
|
147
|
-
en: (
|
|
148
|
-
<>
|
|
149
|
-
Edit <code>src/App.tsx</code> and save to reload
|
|
150
|
-
</>
|
|
151
|
-
),
|
|
152
|
-
fr: (
|
|
153
|
-
<>
|
|
154
|
-
Éditez <code>src/App.tsx</code> et enregistrez pour recharger
|
|
155
|
-
</>
|
|
156
|
-
),
|
|
157
|
-
es: (
|
|
158
|
-
<>
|
|
159
|
-
Edita <code>src/App.tsx</code> y guarda para recargar
|
|
160
|
-
</>
|
|
161
|
-
),
|
|
162
|
-
}),
|
|
163
|
-
reactLink: {
|
|
164
|
-
href: "https://reactjs.org",
|
|
165
|
-
content: t({
|
|
166
|
-
en: "Learn React",
|
|
167
|
-
fr: "Apprendre React",
|
|
168
|
-
es: "Aprender React",
|
|
169
|
-
}),
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
} satisfies DeclarationContent;
|
|
173
|
-
|
|
174
|
-
export default appContent;
|
|
42
|
+
```bash packageManager="yarn"
|
|
43
|
+
yarn add vite-intlayer
|
|
175
44
|
```
|
|
176
45
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
## Step 5: Utilize Intlayer in Your Code
|
|
180
|
-
|
|
181
|
-
Access your content dictionaries throughout your application:
|
|
182
|
-
|
|
183
|
-
```tsx
|
|
184
|
-
import logo from "./logo.svg";
|
|
185
|
-
import "./App.css";
|
|
186
|
-
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
187
|
-
import { LocaleSwitcher } from "./components/LangSwitcherDropDown";
|
|
188
|
-
|
|
189
|
-
function AppContent() {
|
|
190
|
-
const content = useIntlayer("app");
|
|
191
|
-
|
|
192
|
-
return (
|
|
193
|
-
<header className="App-header">
|
|
194
|
-
<img src={logo} className="App-logo" alt="logo" />
|
|
195
|
-
|
|
196
|
-
{content.getStarted}
|
|
197
|
-
<a
|
|
198
|
-
className="App-link"
|
|
199
|
-
href={content.reactLink.href.value}
|
|
200
|
-
target="_blank"
|
|
201
|
-
rel="noopener noreferrer"
|
|
202
|
-
>
|
|
203
|
-
{content.reactLink.content}
|
|
204
|
-
</a>
|
|
205
|
-
</header>
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function App() {
|
|
210
|
-
return (
|
|
211
|
-
<IntlayerProvider>
|
|
212
|
-
<div className="App">
|
|
213
|
-
{/* To use the useIntlayer hook properly, you should access your data in a children component */}
|
|
214
|
-
<AppContent />
|
|
215
|
-
</div>
|
|
216
|
-
<div className="absolute bottom-5 right-5 z-50">
|
|
217
|
-
<LocaleSwitcher />
|
|
218
|
-
</div>
|
|
219
|
-
</IntlayerProvider>
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export default App;
|
|
46
|
+
```bash packageManager="pnpm"
|
|
47
|
+
pnpm add vite-intlayer
|
|
224
48
|
```
|
|
225
49
|
|
|
226
|
-
|
|
227
|
-
>
|
|
228
|
-
> ```tsx
|
|
229
|
-
> <img src={content.image.src.value} alt={content.image.value} />
|
|
230
|
-
> ```
|
|
231
|
-
|
|
232
|
-
## (Optional) Step 6: Change the language of your content
|
|
233
|
-
|
|
234
|
-
To change the language of your content, you can use the `setLocale` function provided by the `useLocale` hook. This function allows you to set the locale of the application and update the content accordingly.
|
|
50
|
+
## Example of usage
|
|
235
51
|
|
|
236
|
-
|
|
237
|
-
import { Locales } from "intlayer";
|
|
238
|
-
import { useLocale } from "react-intlayer";
|
|
52
|
+
See an example of how to include the plugins into your vite configuration.
|
|
239
53
|
|
|
240
|
-
|
|
241
|
-
|
|
54
|
+
```typescript fileName="vite.config.ts"
|
|
55
|
+
import { defineConfig } from "vite";
|
|
56
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
242
57
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
);
|
|
248
|
-
};
|
|
58
|
+
// https://vitejs.dev/config/
|
|
59
|
+
export default defineConfig({
|
|
60
|
+
plugins: [intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
61
|
+
});
|
|
249
62
|
```
|
|
250
63
|
|
|
251
|
-
|
|
64
|
+
> The `intlayerPlugin()` Vite plugin is used to integrate Intlayer with Vite. It ensures the building of content declaration files and monitors them in development mode. It defines Intlayer environment variables within the Vite application. Additionally, it provides aliases to optimize performance.
|
|
252
65
|
|
|
253
|
-
|
|
66
|
+
> The `intLayerMiddlewarePlugin()` add server-side routing to your application. This plugin will automatically detect the current locale based on the URL and set the appropriate locale cookie. If no locale is specified, the plugin will determine the most appropriate locale based on the user's browser language preferences. If no locale is detected, it will redirect to the default locale.
|
|
254
67
|
|
|
255
|
-
|
|
68
|
+
## Mastering the internationalization of your Vite application
|
|
256
69
|
|
|
257
|
-
|
|
70
|
+
Intlayer provides a lot of features to help you internationalize your Vite application.
|
|
258
71
|
|
|
259
|
-
|
|
72
|
+
**To learn more about these features, refer to the [React Internationalization (i18n) with Intlayer and Vite and React](https://github.com/aymericzip/intlayer/blob/main/docs/en/intlayer_with_vite+react.md) guide for Vite and React Application.**
|
|
260
73
|
|
|
261
|
-
|
|
262
|
-
// tsconfig.json
|
|
263
|
-
|
|
264
|
-
{
|
|
265
|
-
// your custom config
|
|
266
|
-
"include": [
|
|
267
|
-
"src",
|
|
268
|
-
"types", // <- Include the auto generated types
|
|
269
|
-
],
|
|
270
|
-
}
|
|
271
|
-
```
|
|
74
|
+
## Read about Intlayer
|
|
272
75
|
|
|
273
|
-
|
|
76
|
+
- [Intlayer Website](https://intlayer.org)
|
|
77
|
+
- [Intlayer Documentation](https://intlayer.org/docs)
|
|
78
|
+
- [Intlayer GitHub](https://github.com/aymericzip/intlayer)
|
|
274
79
|
|
|
275
|
-
|
|
80
|
+
- [Ask your questions to our smart documentation](https://intlayer.org/docs/chat)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport process from 'process';\nimport { watch } from '@intlayer/chokidar';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { loadEnv, type Plugin } from 'vite';\n\n// Plugin options type definition\ntype PluginOptions = {\n // Custom options for your plugin, if any\n};\n\n/**\n *\n * A Vite plugin that integrates
|
|
1
|
+
{"version":3,"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport process from 'process';\nimport { watch } from '@intlayer/chokidar';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { loadEnv, type Plugin } from 'vite';\n\n// Plugin options type definition\ntype PluginOptions = {\n // Custom options for your plugin, if any\n};\n\n/**\n *\n * A Vite plugin that integrates Intlayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intlayerPlugin() ],\n * });\n * ```\n * */\nexport const intlayerPlugin = (_pluginOptions: PluginOptions = {}): Plugin => ({\n name: 'vite-intlayer-plugin',\n\n config: (config, { mode }) => {\n const intlayerConfig = getConfiguration();\n const { mainDir, baseDir, watch: isWatchMode } = intlayerConfig.content;\n\n // Set all configuration values as environment variables\n const env = formatEnvVariable('vite');\n\n process.env = {\n ...process.env,\n ...loadEnv(mode, process.cwd()),\n ...env,\n };\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n },\n };\n\n if (isWatchMode) {\n // Ajout de l'option optimizeDeps.exclude\n config.optimizeDeps = {\n ...config.optimizeDeps,\n exclude: [\n ...(config.optimizeDeps?.exclude || []),\n '@intlayer/dictionaries-entry',\n ],\n };\n }\n\n const externals: string[] = (config.build?.rollupOptions?.external ??\n []) as string[];\n\n config.build = {\n ...config.build,\n rollupOptions: {\n ...config.build?.rollupOptions,\n external: [...externals, 'module'],\n },\n };\n\n return config;\n },\n\n buildStart: () => {\n // Code to run when Vite build starts\n watch();\n },\n configureServer: () => {\n // Custom server configuration, if needed\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwC;AACxC,qBAAoB;AACpB,sBAAsB;AACtB,oBAAoD;AAEpD,kBAAqC;AAkB9B,MAAM,iBAAiB,CAAC,iBAAgC,CAAC,OAAe;AAAA,EAC7E,MAAM;AAAA,EAEN,QAAQ,CAAC,QAAQ,EAAE,KAAK,MAAM;AAC5B,UAAM,qBAAiB,gCAAiB;AACxC,UAAM,EAAE,SAAS,SAAS,OAAO,YAAY,IAAI,eAAe;AAGhE,UAAM,UAAM,iCAAkB,MAAM;AAEpC,mBAAAA,QAAQ,MAAM;AAAA,MACZ,GAAG,eAAAA,QAAQ;AAAA,MACX,OAAG,qBAAQ,MAAM,eAAAA,QAAQ,IAAI,CAAC;AAAA,MAC9B,GAAG;AAAA,IACL;AAEA,UAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,UAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAGnE,WAAO,UAAU;AAAA,MACf,GAAG,OAAO;AAAA,MACV,OAAO;AAAA,QACL,GAAG,OAAO,SAAS;AAAA,QACnB,oCAAgC,qBAAQ,wBAAwB;AAAA,MAClE;AAAA,IACF;AAEA,QAAI,aAAa;AAEf,aAAO,eAAe;AAAA,QACpB,GAAG,OAAO;AAAA,QACV,SAAS;AAAA,UACP,GAAI,OAAO,cAAc,WAAW,CAAC;AAAA,UACrC;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,UAAM,YAAuB,OAAO,OAAO,eAAe,YACxD,CAAC;AAEH,WAAO,QAAQ;AAAA,MACb,GAAG,OAAO;AAAA,MACV,eAAe;AAAA,QACb,GAAG,OAAO,OAAO;AAAA,QACjB,UAAU,CAAC,GAAG,WAAW,QAAQ;AAAA,MACnC;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,MAAM;AAEhB,+BAAM;AAAA,EACR;AAAA,EACA,iBAAiB,MAAM;AAAA,EAEvB;AACF;","names":["process"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport process from 'process';\nimport { watch } from '@intlayer/chokidar';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { loadEnv, type Plugin } from 'vite';\n\n// Plugin options type definition\ntype PluginOptions = {\n // Custom options for your plugin, if any\n};\n\n/**\n *\n * A Vite plugin that integrates
|
|
1
|
+
{"version":3,"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport process from 'process';\nimport { watch } from '@intlayer/chokidar';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { loadEnv, type Plugin } from 'vite';\n\n// Plugin options type definition\ntype PluginOptions = {\n // Custom options for your plugin, if any\n};\n\n/**\n *\n * A Vite plugin that integrates Intlayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intlayerPlugin() ],\n * });\n * ```\n * */\nexport const intlayerPlugin = (_pluginOptions: PluginOptions = {}): Plugin => ({\n name: 'vite-intlayer-plugin',\n\n config: (config, { mode }) => {\n const intlayerConfig = getConfiguration();\n const { mainDir, baseDir, watch: isWatchMode } = intlayerConfig.content;\n\n // Set all configuration values as environment variables\n const env = formatEnvVariable('vite');\n\n process.env = {\n ...process.env,\n ...loadEnv(mode, process.cwd()),\n ...env,\n };\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n },\n };\n\n if (isWatchMode) {\n // Ajout de l'option optimizeDeps.exclude\n config.optimizeDeps = {\n ...config.optimizeDeps,\n exclude: [\n ...(config.optimizeDeps?.exclude || []),\n '@intlayer/dictionaries-entry',\n ],\n };\n }\n\n const externals: string[] = (config.build?.rollupOptions?.external ??\n []) as string[];\n\n config.build = {\n ...config.build,\n rollupOptions: {\n ...config.build?.rollupOptions,\n external: [...externals, 'module'],\n },\n };\n\n return config;\n },\n\n buildStart: () => {\n // Code to run when Vite build starts\n watch();\n },\n configureServer: () => {\n // Custom server configuration, if needed\n },\n});\n"],"mappings":"AAAA,SAAS,MAAM,UAAU,eAAe;AACxC,OAAO,aAAa;AACpB,SAAS,aAAa;AACtB,SAAS,kBAAkB,yBAAyB;AAEpD,SAAS,eAA4B;AAkB9B,MAAM,iBAAiB,CAAC,iBAAgC,CAAC,OAAe;AAAA,EAC7E,MAAM;AAAA,EAEN,QAAQ,CAAC,QAAQ,EAAE,KAAK,MAAM;AAC5B,UAAM,iBAAiB,iBAAiB;AACxC,UAAM,EAAE,SAAS,SAAS,OAAO,YAAY,IAAI,eAAe;AAGhE,UAAM,MAAM,kBAAkB,MAAM;AAEpC,YAAQ,MAAM;AAAA,MACZ,GAAG,QAAQ;AAAA,MACX,GAAG,QAAQ,MAAM,QAAQ,IAAI,CAAC;AAAA,MAC9B,GAAG;AAAA,IACL;AAEA,UAAM,mBAAmB,KAAK,SAAS,kBAAkB;AACzD,UAAM,2BAA2B,SAAS,SAAS,gBAAgB;AAGnE,WAAO,UAAU;AAAA,MACf,GAAG,OAAO;AAAA,MACV,OAAO;AAAA,QACL,GAAG,OAAO,SAAS;AAAA,QACnB,gCAAgC,QAAQ,wBAAwB;AAAA,MAClE;AAAA,IACF;AAEA,QAAI,aAAa;AAEf,aAAO,eAAe;AAAA,QACpB,GAAG,OAAO;AAAA,QACV,SAAS;AAAA,UACP,GAAI,OAAO,cAAc,WAAW,CAAC;AAAA,UACrC;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,UAAM,YAAuB,OAAO,OAAO,eAAe,YACxD,CAAC;AAEH,WAAO,QAAQ;AAAA,MACb,GAAG,OAAO;AAAA,MACV,eAAe;AAAA,QACb,GAAG,OAAO,OAAO;AAAA,QACjB,UAAU,CAAC,GAAG,WAAW,QAAQ;AAAA,MACnC;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,MAAM;AAEhB,UAAM;AAAA,EACR;AAAA,EACA,iBAAiB,MAAM;AAAA,EAEvB;AACF;","names":[]}
|
|
@@ -2,7 +2,7 @@ import { type Plugin } from 'vite';
|
|
|
2
2
|
type PluginOptions = {};
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
|
-
* A Vite plugin that integrates
|
|
5
|
+
* A Vite plugin that integrates Intlayer configuration into the build process
|
|
6
6
|
*
|
|
7
7
|
* ```ts
|
|
8
8
|
* // Example usage of the plugin in a Vite configuration
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-intlayer",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "A Vite plugin for seamless internationalization (i18n), providing locale detection, redirection, and environment-based configuration",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"intlayer",
|
|
8
8
|
"data",
|
|
@@ -40,31 +40,6 @@
|
|
|
40
40
|
"require": "./dist/cjs/index.cjs",
|
|
41
41
|
"import": "./dist/esm/index.mjs"
|
|
42
42
|
},
|
|
43
|
-
"./server": {
|
|
44
|
-
"types": "./dist/types/server/index.d.ts",
|
|
45
|
-
"require": "./dist/cjs/server/index.cjs",
|
|
46
|
-
"import": "./dist/esm/server/index.mjs"
|
|
47
|
-
},
|
|
48
|
-
"./craco-plugin": {
|
|
49
|
-
"types": "./dist/types/craco/intlayerCracoPlugin.d.ts",
|
|
50
|
-
"require": "./dist/cjs/craco/intlayerCracoPlugin.cjs",
|
|
51
|
-
"import": "./dist/esm/craco/intlayerCracoPlugin.mjs"
|
|
52
|
-
},
|
|
53
|
-
"./craco-config": {
|
|
54
|
-
"types": "./dist/types/craco/craco.config.d.ts",
|
|
55
|
-
"require": "./dist/cjs/craco/craco.config.cjs",
|
|
56
|
-
"import": "./dist/esm/craco/craco.config.mjs"
|
|
57
|
-
},
|
|
58
|
-
"./vite": {
|
|
59
|
-
"types": "./dist/types/vite/index.d.ts",
|
|
60
|
-
"require": "./dist/cjs/vite/index.cjs",
|
|
61
|
-
"import": "./dist/esm/vite/index.mjs"
|
|
62
|
-
},
|
|
63
|
-
"./editor": {
|
|
64
|
-
"types": "./dist/types/editor/index.d.ts",
|
|
65
|
-
"require": "./dist/cjs/editor/index.cjs",
|
|
66
|
-
"import": "./dist/esm/editor/index.mjs"
|
|
67
|
-
},
|
|
68
43
|
"./package.json": "./package.json"
|
|
69
44
|
},
|
|
70
45
|
"main": "dist/cjs/index.cjs",
|
|
@@ -83,9 +58,9 @@
|
|
|
83
58
|
],
|
|
84
59
|
"dependencies": {
|
|
85
60
|
"vite": "^6.0.7",
|
|
86
|
-
"@intlayer/
|
|
87
|
-
"@intlayer/
|
|
88
|
-
"@intlayer/
|
|
61
|
+
"@intlayer/chokidar": "4.0.3",
|
|
62
|
+
"@intlayer/config": "4.0.3",
|
|
63
|
+
"@intlayer/core": "4.0.3"
|
|
89
64
|
},
|
|
90
65
|
"devDependencies": {
|
|
91
66
|
"@types/node": "^22.10.6",
|
|
@@ -97,16 +72,16 @@
|
|
|
97
72
|
"tsc-alias": "^1.8.10",
|
|
98
73
|
"tsup": "^8.3.5",
|
|
99
74
|
"typescript": "^5.7.3",
|
|
75
|
+
"@utils/ts-config-types": "1.0.4",
|
|
100
76
|
"@utils/eslint-config": "1.0.4",
|
|
101
|
-
"@utils/tsup-config": "1.0.4",
|
|
102
77
|
"@utils/ts-config": "1.0.4",
|
|
103
|
-
"@utils/
|
|
78
|
+
"@utils/tsup-config": "1.0.4"
|
|
104
79
|
},
|
|
105
80
|
"peerDependencies": {
|
|
106
81
|
"vite": ">=4.0.0",
|
|
107
|
-
"@intlayer/chokidar": "4.0.
|
|
108
|
-
"@intlayer/
|
|
109
|
-
"@intlayer/
|
|
82
|
+
"@intlayer/chokidar": "4.0.3",
|
|
83
|
+
"@intlayer/config": "4.0.3",
|
|
84
|
+
"@intlayer/core": "4.0.3"
|
|
110
85
|
},
|
|
111
86
|
"engines": {
|
|
112
87
|
"node": ">=14.18"
|