小编prv*_*ist的帖子

[NextJs/TailwindCSS]:生产中缺少 css 类

顺风版: v9.3.5

PostCSS 配置:

// postcss.config.js

module.exports = {
   plugins: {
      tailwindcss: {},
      autoprefixer: {},
      ...(process.env.NODE_ENV === 'production'
         ? {
              '@fullhuman/postcss-purgecss': {
                 content: ['./components/**/*.js', './pages/**/*.js'],
                 defaultExtractor: content =>
                    content.match(/[\w-/:]+(?<!:)/g) || [],
              },
           }
         : {}),
   },
}
Run Code Online (Sandbox Code Playgroud)

顺风配置:

// tailwind.config.js

module.exports = {
   theme: {
      extend: {
         colors: {
            tint: 'rgba(0,0,0,0.3)',
         },
      },
   },
   variants: {},
   plugins: [],
}

Run Code Online (Sandbox Code Playgroud)

样式在开发中完美运行,但在生产中只有一些样式有效。在检查 build 文件夹中的 CSS 文件时,看起来某些 CSS 类没有被提取或可能被清除,因此导致应用程序的部分样式。

css reactjs next.js tailwind-css

5
推荐指数
2
解决办法
4672
查看次数

使用 graphql union 返回一个包含一些空对象的数组

我正在使用 graphql union - union FolderOrFile = Folder | File。当我仅查询文件夹时,我得到的数组包含带有空对象的文件夹对象,这些对象基本上是文件对象。

类型定义

const typeDefs = gql`
    union FolderOrFile = Folder | File
    type Folder {
        name: String
        path: String
        type: String
        children: [FolderOrFile]
    }
    type File {
        name: String
        path: String
        content: String
        type: String
        size: Int
        ext: String
        createdAt: String
    }
    type Query {
        folders: Folder
    }
`
Run Code Online (Sandbox Code Playgroud)

旋转变压器

const resolvers = {
    FolderOrFile: {
        __resolveType: obj => {
            if (obj.type === "file") {
                return 'File'
            }
            if (obj.type …
Run Code Online (Sandbox Code Playgroud)

union apollo graphql

3
推荐指数
1
解决办法
2042
查看次数

标签 统计

apollo ×1

css ×1

graphql ×1

next.js ×1

reactjs ×1

tailwind-css ×1

union ×1