@intlify/unplugin-vue-i18n 0.7.1 → 0.7.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/lib/index.cjs +17 -6
- package/lib/index.mjs +17 -6
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -147,7 +147,10 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
147
147
|
enforce: meta.framework === "vite" ? "pre" : "post",
|
|
148
148
|
vite: {
|
|
149
149
|
config(config, { command }) {
|
|
150
|
-
|
|
150
|
+
config.resolve = normalizeConfigResolveAlias(
|
|
151
|
+
config.resolve,
|
|
152
|
+
meta.framework
|
|
153
|
+
);
|
|
151
154
|
if (command === "build" && runtimeOnly) {
|
|
152
155
|
const aliasName = getAliasName();
|
|
153
156
|
debug(`alias name: ${aliasName}`);
|
|
@@ -163,7 +166,10 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
163
166
|
`set ${aliasName} runtime only: ${aliasName}/dist/${aliasName}.runtime.esm-bundler.js`
|
|
164
167
|
);
|
|
165
168
|
} else if (command === "serve" && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
|
|
166
|
-
|
|
169
|
+
config.resolve = normalizeConfigResolveAlias(
|
|
170
|
+
config.resolve,
|
|
171
|
+
meta.framework
|
|
172
|
+
);
|
|
167
173
|
if (shared.isArray(config.resolve.alias)) {
|
|
168
174
|
config.resolve.alias.push({
|
|
169
175
|
find: "vue-i18n",
|
|
@@ -224,7 +230,10 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
224
230
|
sourceMap = !!compiler.options.devtool;
|
|
225
231
|
debug(`webpack: isProduction = ${isProduction}, sourceMap = ${sourceMap}`);
|
|
226
232
|
if (isProduction && runtimeOnly) {
|
|
227
|
-
|
|
233
|
+
compiler.options.resolve = normalizeConfigResolveAlias(
|
|
234
|
+
compiler.options.resolve,
|
|
235
|
+
meta.framework
|
|
236
|
+
);
|
|
228
237
|
compiler.options.resolve.alias["vue-i18n"] = `vue-i18n/dist/vue-i18n.runtime.esm-bundler.js`;
|
|
229
238
|
}
|
|
230
239
|
loadWebpack().then((webpack) => {
|
|
@@ -396,19 +405,21 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
396
405
|
});
|
|
397
406
|
function normalizeConfigResolveAlias(resolve, framework) {
|
|
398
407
|
if (resolve && resolve.alias) {
|
|
399
|
-
return;
|
|
408
|
+
return resolve;
|
|
400
409
|
}
|
|
401
410
|
if (!resolve) {
|
|
402
411
|
if (framework === "vite") {
|
|
403
|
-
|
|
412
|
+
return { alias: [] };
|
|
404
413
|
} else if (framework === "webpack") {
|
|
405
|
-
|
|
414
|
+
return { alias: {} };
|
|
406
415
|
}
|
|
407
416
|
} else if (!resolve.alias) {
|
|
408
417
|
if (framework === "vite") {
|
|
409
418
|
resolve.alias = [];
|
|
419
|
+
return resolve;
|
|
410
420
|
} else if (framework === "webpack") {
|
|
411
421
|
resolve.alias = {};
|
|
422
|
+
return resolve;
|
|
412
423
|
}
|
|
413
424
|
}
|
|
414
425
|
}
|
package/lib/index.mjs
CHANGED
|
@@ -135,7 +135,10 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
135
135
|
enforce: meta.framework === "vite" ? "pre" : "post",
|
|
136
136
|
vite: {
|
|
137
137
|
config(config, { command }) {
|
|
138
|
-
|
|
138
|
+
config.resolve = normalizeConfigResolveAlias(
|
|
139
|
+
config.resolve,
|
|
140
|
+
meta.framework
|
|
141
|
+
);
|
|
139
142
|
if (command === "build" && runtimeOnly) {
|
|
140
143
|
const aliasName = getAliasName();
|
|
141
144
|
debug(`alias name: ${aliasName}`);
|
|
@@ -151,7 +154,10 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
151
154
|
`set ${aliasName} runtime only: ${aliasName}/dist/${aliasName}.runtime.esm-bundler.js`
|
|
152
155
|
);
|
|
153
156
|
} else if (command === "serve" && installedPkg === "petite-vue-i18n" && useVueI18nImportName) {
|
|
154
|
-
|
|
157
|
+
config.resolve = normalizeConfigResolveAlias(
|
|
158
|
+
config.resolve,
|
|
159
|
+
meta.framework
|
|
160
|
+
);
|
|
155
161
|
if (isArray(config.resolve.alias)) {
|
|
156
162
|
config.resolve.alias.push({
|
|
157
163
|
find: "vue-i18n",
|
|
@@ -212,7 +218,10 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
212
218
|
sourceMap = !!compiler.options.devtool;
|
|
213
219
|
debug(`webpack: isProduction = ${isProduction}, sourceMap = ${sourceMap}`);
|
|
214
220
|
if (isProduction && runtimeOnly) {
|
|
215
|
-
|
|
221
|
+
compiler.options.resolve = normalizeConfigResolveAlias(
|
|
222
|
+
compiler.options.resolve,
|
|
223
|
+
meta.framework
|
|
224
|
+
);
|
|
216
225
|
compiler.options.resolve.alias["vue-i18n"] = `vue-i18n/dist/vue-i18n.runtime.esm-bundler.js`;
|
|
217
226
|
}
|
|
218
227
|
loadWebpack().then((webpack) => {
|
|
@@ -384,19 +393,21 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
384
393
|
});
|
|
385
394
|
function normalizeConfigResolveAlias(resolve, framework) {
|
|
386
395
|
if (resolve && resolve.alias) {
|
|
387
|
-
return;
|
|
396
|
+
return resolve;
|
|
388
397
|
}
|
|
389
398
|
if (!resolve) {
|
|
390
399
|
if (framework === "vite") {
|
|
391
|
-
|
|
400
|
+
return { alias: [] };
|
|
392
401
|
} else if (framework === "webpack") {
|
|
393
|
-
|
|
402
|
+
return { alias: {} };
|
|
394
403
|
}
|
|
395
404
|
} else if (!resolve.alias) {
|
|
396
405
|
if (framework === "vite") {
|
|
397
406
|
resolve.alias = [];
|
|
407
|
+
return resolve;
|
|
398
408
|
} else if (framework === "webpack") {
|
|
399
409
|
resolve.alias = {};
|
|
410
|
+
return resolve;
|
|
400
411
|
}
|
|
401
412
|
}
|
|
402
413
|
}
|