codecamp

Windi CSS Gridsome

安装

yarn add gridsome-plugin-windicss -D
# npm i gridsome-plugin-windicss -D

⚠️ 此模块是预发布版,请报告您发现的任何问题

用法

在您的 gridsome.config.js 中添加以下内容。

gridsome.config.js

export default {
  // ...
  plugins: [
    {
      use: 'gridsome-plugin-windicss',
      options: {
        // see https://github.com/windicss/vite-plugin-windicss/blob/main/packages/plugin-utils/src/options.ts
      },
    },
  ],
}

此模块不适用于 gridsome-plugin-tailwindcss,您需要将其删除。

 plugins: [
    {
-      use: 'gridsome-plugin-tailwindcss',
-      options: {
-        // ...
-      }
    },
  ],

如果您有 ​tailwind.config.js​,请将其重命名为 ​windi.config.js​ 或 ​windi.config.ts​。

迁移

如果您以前使用过 gridsome-plugin-tailwindcss,请参阅有关迁移的文档。

配置

  • 默认:
export default {
  scan: {
    dirs: ['./'],
    exclude: [
      'node_modules',
      '.git',
      'dist',
      '.cache',
      '*.template.html',
      'app.html',
    ],
    include: [],
  },
  transformCSS: 'pre',
  preflight: {
    alias: {
      // add gridsome aliases
      'g-link': 'a',
      'g-image': 'img',
    },
  },
}

例子

禁用预检

gridsome.config.js

export default {
  // ...
  plugins: [
    {
      use: 'gridsome-plugin-windicss',
      options: {
        preflight: false,
      },
    },
  ],
}

注意事项

Scoped Style

具有作用域样式的 @media 指令只能与 css postcss scss 一起使用,但不能与 sass、less 或 stylus 一起使用


Windi CSS Vue CLI
Windi CSS Svelte
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }