简体   繁体   English

如何从css文件中删除css注释

[英]how to remove css comments from css file

I am using nextjs + reactjs .I want to remove all css comments present in my css file.我正在使用nextjs + reactjs 。我想remove我的css文件中存在的所有 css 注释。 For example, a created a simple project for next js.例如,a为next js创建了一个简单的项目。 I am using next-purgecss to remove unwanted css but still, it is not removing comments why?我正在使用next-purgecss删除不需要的 css,但仍然没有removing评论,为什么?

here is my code https://codesandbox.io/s/sharp-jennings-upb7y?file=/next.config.js:73-86 I added a comment in my css file这是我的代码https://codesandbox.io/s/sharp-jennings-upb7y?file=/next.config.js:73-86我在我的css文件中添加了一条comment

/*

heloo terr
 */
a {
  background-color: green;
}

It should be removed after using purgecss plugin.Is there any way to remove these comments使用purgecss插件后应该删除它。有什么方法可以删除这些评论

在此处输入图片说明

To run code create a new terminal and run npm run dev as it open at 3005 port要运行代码,请创建一个新终端并在它在3005端口打开时运行npm run dev

在此处输入图片说明

Next.js removes comments in CSS automatically. Next.js 自动删除 CSS 中的注释。 You don't need an extra configuration or CSS processing packages.您不需要额外的配置或 CSS 处理包。 Run the project in production mode using npm run build and npm start and comments would be removed from the build.使用npm run buildnpm start在生产模式下运行项目,注释将从构建中删除。

Generally, in development mode ( next dev ), the build is not optimized for production.通常,在开发模式 ( next dev ) 中,构建不会针对生产进行优化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM