构建electron项目

1. 使用electron-vite构建工具

官网链接
安装构建工具

typescript 复制代码
pnpm i electron-vite -g

创建electron-vite项目

typescript 复制代码
pnpm create @quick-start/electron

安装所有依赖

typescript 复制代码
pnpm i

其他

typescript 复制代码
pnpm -D add sass scss

1. 启动项目

2. 配置

  • package.json
typescript 复制代码
"dev": "electron-vite dev --watch",

2. 使用tailwind

tailwind官网

安装

typescript 复制代码
pnpm add -D tailwindcss postcss autoprefixer  

初始化tailwindcss

  • 创建两个配置文件
typescript 复制代码
npx tailwindcss init -p
// Created Tailwind CSS config file: tailwind.config.js
// Created PostCSS config file: postcss.config.js

修改tailwind.config.js

  • 官网上缺少vue的配置
typescript 复制代码
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
  theme: {
    extend: {}
  },
  plugins: []
}

renderer/src目录创建index.css文件

typescript 复制代码
@tailwind base;
@tailwind components;
@tailwind utilities;

在main.ts文件中引入index.css

  • 脚手架自动创建了别名:@renderer': resolve('src/renderer/src')
typescript 复制代码
import { createApp } from 'vue'
import App from './App.vue'
import '@renderer/index.css'

createApp(App).mount('#app')

安装插件Tailwind CSS IntelliSense

  • 插件的作用:写tailwind代码就有提示了

App.vue

  • 测试tailwind是否可以使用
typescript 复制代码
<div class="bg-red-600">tailwind测试</div>

打包

electron-vite 打包makensis.exe报错解决记录

相关推荐
Sheldon一蓑烟雨任平生4 小时前
Vue3 列表渲染
vue.js·vue3·v-for·列表渲染·vue3 列表渲染·v-for 循环对象·v-for与计算属性
duansamve12 小时前
TS在Vue3中的使用实例集合
typescript·vue3
ღ᭄ꦿ࿐Never say never꧂15 小时前
微信小程序 Button 组件 open-type 完全指南:从用户信息获取到客服分享的实战应用
spring boot·微信小程序·小程序·uni-app·vue3
给冲儿来刀狠的1 天前
解决electron-build报错:cannot find module/Please verify that the package . json has
electron
SanOrintea1 天前
electron中进程线程之间通信方式
服务器·javascript·electron
Sheldon一蓑烟雨任平生1 天前
Vue3 Class 与 Style 绑定
vue.js·vue3·class与style绑定·绑定class·绑定style·vue3绑定class·vue3绑定style
toobeloong2 天前
Electron 从低版本升级到高版本 - 开始使用@electron/remote的改造教程
前端·javascript·electron
酷柚易汛智推官3 天前
Electron技术深度解析:跨平台桌面开发的利器与挑战
前端·javascript·electron
长明4 天前
Electron 的西天取经
vue.js·electron