Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“顺风”css在清除后不会减少文件大小_Css_Tailwind Css - Fatal编程技术网

“顺风”css在清除后不会减少文件大小

“顺风”css在清除后不会减少文件大小,css,tailwind-css,Css,Tailwind Css,我有一个基本的html文件(index.html),我的项目结构如下: index.html tailwind.config.js postss.js tailwind.css dist.css 这里是每个文件的内容 module.exports = { purge: { enabled:true, content:['./*.html', './**/*.html'], layers: ['components'] }, theme: { extend: {

我有一个基本的html文件(index.html),我的项目结构如下:

  • index.html
  • tailwind.config.js
  • postss.js
  • tailwind.css
  • dist.css
这里是每个文件的内容

module.exports = {
purge: {
    enabled:true,
    content:['./*.html', './**/*.html'],
    layers: ['components']
},
theme: {
    extend: {
        fontSize:{
            'small' : '.6rem',
            // Or with a default line-height as well
            '3xl': ['2.5rem', {
                lineHeight: '50px',
            }],
            '6xl': ['3.70rem', {
                lineHeight: '60px',
            }],
        },
        colors:{
            transparent: 'transparent',
            current: 'currentColor',
            orange:{
                DEFAULT: '#F47521'
            }
        },
        screens: {
            'sm': '640px',
            'md': '760px',
            'custom' : '980px',
            'lg': '1024px',
            'xl': '1280px',
            '2xl': '1536px',
            '3xl': '1600px',
            'xxl' : '1700px'
        }
    }
},
variants: {
    textColor: ['responsive', 'hover', 'focus', 'visited'],
},
plugins: [
    ({addUtilities}) => {
        const utils = {
            '.translate-x-half': {
                transform: 'translateX(50%)',
            },
        };
        addUtilities(utils, ['responsive'])
    }
]
};
邮政编码文件

module.exports = {
    plugins: {
        tailwindcss: {},
        autoprefixer: {},
    }
}
还有我的package.json

{
  "name": "myproject",
  "version": "1.0.0",
  "description": "my theme",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "NODE_ENV=production npx tailwindcss-cli@latest build tailwind.css -o dist.css",
    "build:css": "postcss tailwind.css -o dist.css"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
  "autoprefixer": "^10.2.5",
  "postcss": "^8.2.8",
  "tailwindcss": "^2.0.4"
  },
   "dependencies": {
      "cssnano": "^4.1.10",
      "postcss-cli": "^8.3.1"
   }
}
当使用:npm run build构建时,tailwind构建项目,但dist.css大小仍然为5,7MB

我做错了什么


谢谢

您已将清除配置为应用于“组件”层

“顺风”有三层:“基础”、“组件”和“实用程序”。组件是三个组件中最小的,因此它对生成的文件大小的影响相当小。你达到了5.7MB,因为到目前为止,最大的层“实用程序”被忽略了

更新清除配置,使其也适用于实用程序。除非有充分的理由对层进行选择,否则您可能希望放弃任何特异性,并允许其应用于所有层

此外,如果您不启用
功能
,它将根据
节点环境
设置自动处理

嘿,关于“公用事业”,你说得对,非常感谢