This commit is contained in:
2023-05-04 15:42:44 +08:00
parent de9695af0e
commit 9f5b7628f0
11 changed files with 525 additions and 15 deletions

9
packages/3-baseconfig/.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
node_modules
*.log*
.nuxt
.nitro
.cache
.output
.env
dist
.DS_Store

View File

@@ -0,0 +1 @@
shamefully-hoist=true

View File

@@ -0,0 +1,40 @@
# 基础配置
## 自定义启动端口
```shell
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devServer: {
port: 3000,
host: "0.0.0.0"
},
})
```
## 自定义样式
```js
// https://nuxt.com/docs/api/configuration/nuxt-config
import { fileURLToPath } from "node:url";
export default defineNuxtConfig({
srcDir: "src",
devServer: {
port: 3000,
host: "0.0.0.0",
},
vite: {
css: {
preprocessorOptions: {
scss: {
additionalData: '@import "@/style/index.scss";',
},
},
},
},
alias: {
"@": fileURLToPath(new URL("./src/", import.meta.url)),
},
});
```

View File

@@ -0,0 +1,22 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
import { fileURLToPath } from "node:url";
export default defineNuxtConfig({
srcDir: "src",
devServer: {
port: 3000,
host: "0.0.0.0"
},
vite: {
css: {
preprocessorOptions: {
scss: {
additionalData: '@import "@/style/index.scss";',
},
},
},
},
alias: {
"@": fileURLToPath(new URL("./src/", import.meta.url)),
},
})

View File

@@ -0,0 +1,15 @@
{
"name": "nuxt-app",
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"devDependencies": {
"@types/node": "^18",
"nuxt": "^3.4.3"
}
}

View File

@@ -0,0 +1,14 @@
<template>
<div>Hello</div>
</template>
<script lang="ts" setup>
onMounted(() => {
console.log("mounted");
});
</script>
<style lang="scss">
div {
s}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -0,0 +1,5 @@
body,html {
width: 100vw;
height: 100vh;
background-color: red;
}

View File

@@ -0,0 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}