Skip to content

Commit

Permalink
feat: model template
Browse files Browse the repository at this point in the history
  • Loading branch information
FliPPeDround committed Jan 31, 2024
1 parent 1281674 commit 2100f73
Show file tree
Hide file tree
Showing 24 changed files with 90 additions and 5 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 8 additions & 5 deletions template/base/vite.config.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ import { defineConfig } from 'vite'
<%_ } _%>

export default defineConfig({
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
plugins: [
<%_ for (const { initializer } of plugins) { _%>
<%_ if (initializer) { _%>
<%- initializer _%>,
<%_ } _%>
<%_ } _%>
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
<%_ if (extraConfig) { _%>
<%- extraConfig _%>,
<%_ } _%>
})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions template/model/uniNetwork/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"devDependencies": {
"@uni-helper/uni-network": "^0.18.0"
}
}
5 changes: 5 additions & 0 deletions template/model/uniPromises/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"devDependencies": {
"@uni-helper/uni-promises": "^0.2.1"
}
}
15 changes: 15 additions & 0 deletions template/model/uniPromises/src/main.js.data.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default function getData({ oldData }) {
const uniUsePlugin = {
id: 'uniUse',
importer: `import 'core-js/actual/array/iterator';
import 'core-js/actual/promise';
import 'core-js/actual/object/assign';
import 'core-js/actual/promise/finally';`,
}
return {
...oldData,
plugins: oldData.plugins.flatMap(plugin =>
plugin.id === 'vue' ? [uniUsePlugin, plugin] : plugin,
),
}
}
18 changes: 18 additions & 0 deletions template/model/uniPromises/vite.config.js.data.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default function getData({ oldData }) {
const promisesextraConfig = {
id: 'uniPromises',
extraConfig: `build: {
target: 'es6',
cssTarget: 'chrome61', // https://cn.vitejs.dev/config/build-options.html#build-csstarget
},
optimizeDeps: {
exclude: ['vue-demi'],
}`,
}
return {
...oldData,
extraConfig: oldData.extraConfig.flatMap(config =>
config.id === 'uniUse' ? [...config, ...promisesextraConfig] : config,
),
}
}
6 changes: 6 additions & 0 deletions template/model/uniUse/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"devDependencies": {
"@uni-helper/uni-use": "^0.19.6",
"@vueuse/core": "^9.0.0"
}
}
15 changes: 15 additions & 0 deletions template/model/uniUse/src/main.js.data.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default function getData({ oldData }) {
const uniUsePlugin = {
id: 'uniUse',
importer: `import 'core-js/actual/array/iterator';
import 'core-js/actual/promise';
import 'core-js/actual/object/assign';
import 'core-js/actual/promise/finally';`,
}
return {
...oldData,
plugins: oldData.plugins.flatMap(plugin =>
plugin.id === 'vue' ? [uniUsePlugin, plugin] : plugin,
),
}
}
18 changes: 18 additions & 0 deletions template/model/uniUse/vite.config.js.data.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default function getData({ oldData }) {
const uniUseextraConfig = {
id: 'uniUse',
extraConfig: `build: {
target: 'es6',
cssTarget: 'chrome61', // https://cn.vitejs.dev/config/build-options.html#build-csstarget
},
optimizeDeps: {
exclude: ['vue-demi'],
}`,
}
return {
...oldData,
extraConfig: oldData.extraConfig.flatMap(config =>
config.id === 'uniPromises' ? [...config, ...uniUseextraConfig] : config,
),
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 2100f73

Please sign in to comment.