在Angular 13制作中,尾风不建立课程

发布于 2025-01-31 21:14:54 字数 1522 浏览 4 评论 0原文

在生产中建立时,我很难赢得逆风。我跟随 Angular Guide 和tailwind在服务时工作正常,但是在构建应用程序时却没有识别HTML文件中的任何类,因此

在构建时不会将它们包括在构建中:警告 - 源文件中未检测到实用程序类。如果这是出乎意料的,请仔细检查 content 在您的尾风CSS配置中。

版本:

  • Angular CLI:13.3.2
  • Angular:13.3.2
  • 节点:16.15.0:16.15.0
  • 软件包:NPM:NPM 7.10.0
  • OS:Win32 x64
  • tailwind:3.0.24

tailwind.config.js 看起来像这样的:

module.exports = {
  content: ['./src/**/*.html'],
  theme: {
    extend: {},
  },
  plugins: [],
};

类的顶部。

/* You can add global styles to this file, and also import other style files */
@tailwind base;
@tailwind components;
@tailwind utilities;

tailwind Imports位于 styles.scss.scss 之 创建了 Postcss配置文件,因为我不确定在引擎盖下的角度汇编以及是否有必要。

module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
};

我尝试

  • 返回到tailwind 2,然后将内容更改为purge(使用启用的内容和设置为true。不起作用)
  • 删除Angular Material CSS进口。 (无法使用)
  • 更改配置content以包括所有内容('./*//*。{html,ts}' - 不起作用)
  • 更改config content要包含特定文件('./ src/app/app.component
  • 。但我不想这样做。)
  • 使用CLI NPX tailwindcss -o /output.css < /code>(正常工作。)

关于我可能做错什么的想法?谢谢!

I'm having trouble getting Tailwind to work when building in production. I followed the Angular guide and tailwind works fine when serving but when building the app it doesn't recognize any of the classes from HTML files and therefore doesn't include them in the build

When building I get this message: warn - No utility classes were detected in your source files. If this is unexpected, double-check thecontentoption in your Tailwind CSS configuration.

versions:

  • Angular CLI: 13.3.2
  • Angular: 13.3.2
  • Node: 16.15.0
  • Package Manager: npm 7.10.0
  • OS: win32 x64
  • Tailwind: 3.0.24

tailwind.config.js looks like this:

module.exports = {
  content: ['./src/**/*.html'],
  theme: {
    extend: {},
  },
  plugins: [],
};

tailwind imports are at the top of styles.scss like so:

/* You can add global styles to this file, and also import other style files */
@tailwind base;
@tailwind components;
@tailwind utilities;

I also created a Postcss config file because I wasn't sure how Angular compiled under the hood and if it was necessary or not.

module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
};

Things I have tried

  • Going back to Tailwind 2 and changing content in the config file to purge (using content and setting enabled to true. Didn't work)
  • Removing angular material css imports. (Didn't work)
  • Changing the config content to include everything ('./**/*.{html,ts}' - didn't work)
  • Changing the config content to include specific files ('./src/app/app.component.{html,ts}' - didn't work)
  • Adding safelist classes (Works, but I don't want to do that.)
  • Use CLI npx tailwindcss -o /output.css (Works fine.)

Any Ideas about what I might be doing wrong? Thanks all!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终难愈 2025-02-07 21:14:54

我能够解决这个问题。我从dist文件夹中的构建脚本中调用ng构建。 tailwind.config.js中的内容路径并未从项目的根部看,它从命令到命令的词根中查找文件。

因此,为了定位/src/app/*,我必须像这样上升一个级别:../ src/**/*。html

I was able to figure this out. I calling ng build from a build script that I had in the dist folder. The content path in tailwind.config.js doesn't look from the root of the project, it looks for files from the root of wherever the command is called from.

So in order to target /src/app/* I had to go up one level like so: ../src/**/*.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文