Skip to content

Commit

Permalink
feat: add windicss
Browse files Browse the repository at this point in the history
  • Loading branch information
ckvv committed Dec 24, 2021
1 parent cbb2e61 commit c3cf5ae
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 349 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
+ `eslint`: 检查语法规则和代码风格
+ `commitlint` & `husky`: 检查commit提交的信息
+ `rollup-plugin-visualizer`: 生成 report.html 以帮助分析包内容
+ `tailwindcss`: 以配置好tailwindcss的方式,自动生成样式文件

# Getting Started

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"eslint-plugin-vue": "^8.2.0",
"husky": "^7.0.4",
"lint-staged": "^12.1.2",
"sass": "^1.44.0",
"standard-version": "^9.3.2",
"tailwindcss": "^3.0.5"
"vite-plugin-windicss": "^1.6.1",
"windicss": "^3.4.0"
},
"lint-staged": {
"*.{js,jsx,vue}": [
Expand Down
5 changes: 0 additions & 5 deletions postcss.config.js

This file was deleted.

35 changes: 0 additions & 35 deletions src/assets/style/index.scss

This file was deleted.

25 changes: 0 additions & 25 deletions src/assets/style/mixin.scss

This file was deleted.

26 changes: 0 additions & 26 deletions src/assets/style/variable.scss

This file was deleted.

8 changes: 1 addition & 7 deletions src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="hello-world">
<div class="hello-world text-center">
<div>
Hello: {{username}}
</div>
Expand Down Expand Up @@ -42,9 +42,3 @@ export default {
},
};
</script>

<style lang="scss">
.hello-world {
text-align: center;
}
</style>
5 changes: 3 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/* eslint-disable */
import { createApp } from 'vue';

import plugins from '@/plugins';
import App from '@/App.vue';
import router from '@/router';
import { userAPI } from '@/api';
import { checkRes } from '@/utils/helpers';
import '@/assets/style/index.scss';
import '@/assets/style/index.css';
import 'virtual:windi.css';

async function getUserInfo() {
const userRes = await userAPI.info();
Expand Down
56 changes: 17 additions & 39 deletions src/views/Sign.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<div class="sign">
<div class="sign-content">
<div class="sign-title text-gray-800">
<div class="sign flex flex-col justify-center items-center h-full">
<div class="md:p-16 md:shadow">
<div class="text-center text-4xl">
vite-element-template
</div>
<el-form :hide-required-asterisk="true" label-position="left" class="sign-form" ref="form" :model="user" label-width="70px">
<el-form class="my-8" :hide-required-asterisk="true" label-position="left" ref="form" :model="user" label-width="70px">
<el-form-item prop="username" label="用户名" :rules="[RULES.username]">
<el-input v-model="user.username"></el-input>
</el-form-item>
Expand All @@ -15,13 +15,15 @@
<el-input v-model="user.checkPassword"></el-input>
</el-form-item>
</el-form>
<div class="sign-operate" v-if="type === TYPE.signin">
<el-button type="primary" @click="signIn">登录</el-button>
<el-button @click="toSignUp">注册</el-button>
</div>
<div class="sign-operate" v-if="type === TYPE.signup">
<el-button type="primary" @click="signUp">注册</el-button>
<el-button @click="toSignIn">返回登录</el-button>
<div class="flex flex-col">
<template v-if="type === TYPE.signin">
<el-button class="sign-btn" type="primary" @click="signIn">登录</el-button>
<el-button class="sign-btn" @click="toSignUp">注册</el-button>
</template>
<template v-if="type === TYPE.signup">
<el-button class="sign-btn" type="primary" @click="signUp">注册</el-button>
<el-button class="sign-btn" @click="toSignIn">返回登录</el-button>
</template>
</div>
</div>
</div>
Expand Down Expand Up @@ -94,32 +96,8 @@ export default {
};
</script>

<style lang="scss">
.sign {
flex-direction: column;
@include fill-center;
.sign-content {
@media screen and (min-width: $xs-screen) {
padding: 4rem;
@include box-shadow;
}
.sign-title {
font-size: 2rem;
text-align: center;
}
.sign-form {
margin: 2rem 0;
}
.sign-operate {
display: flex;
flex-direction: column;
.el-button {
width: 100%;
margin: .5rem 0;
}
}
}
}
<style scoped>
.sign-btn {
@apply w-full my-2 !mx-0;
}
</style>
11 changes: 3 additions & 8 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import path from 'path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
// eslint-disable-next-line import/no-extraneous-dependencies
import WindiCSS from 'vite-plugin-windicss';
import { visualizer } from 'rollup-plugin-visualizer';
import PACKAGE from './package.json';

Expand All @@ -14,20 +16,13 @@ visualizerPlugin.outputOptions = () => {
console.info(`\nReport: file://${__dirname}/report/report.html\n`);
};

const plugins = [vue(), visualizerPlugin];
const plugins = [WindiCSS(), vue(), visualizerPlugin];

// https://vitejs.dev/config/
export default defineConfig({
server: {
port: 8000,
},
css: {
preprocessorOptions: {
scss: {
additionalData: '@use "@/assets/style/mixin.scss" as *;\n@use "@/assets/style/variable.scss" as *;',
},
},
},
plugins,
// @开头的路径,会导致vscode 无法语法提示,需配合jsconfig.json使用
// 参考: https://code.visualstudio.com/docs/languages/jsconfig
Expand Down
Loading

0 comments on commit c3cf5ae

Please sign in to comment.