你如何使用 Tailwind.css 构建 npm?
Posted
技术标签:
【中文标题】你如何使用 Tailwind.css 构建 npm?【英文标题】:How do you npm build with Tailwind.css? 【发布时间】:2021-05-22 02:09:49 【问题描述】:我已经使用 Node、Tailwindcss 和 Alpine js 完成了基本站点。每当我运行诸如“npm start”或“npm build”之类的命令时,都会出现错误。
iMac:dmMySite21 eginoj$ npm start
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/eginoj/.npm/_logs/2021-02-19T03_12_40_559Z-debug.log
iMac:dmMySite21 eginoj$ npm start
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/eginoj/.npm/_logs/2021-02-19T03_13_12_384Z-debug.log
这是我的 package.json
"name": "y",
"version": "1.0.0",
"description": "y",
"main": "index.js",
"scripts":
"build-css": "tailwindcss build src/styles.css -o public/styles.css"
,
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies":
"autoprefixer": "^10.2.4",
"nodemon": "^2.0.7",
"postcss": "^8.2.6",
"tailwindcss": "^2.0.3"
,
"dependencies":
"alpinejs": "^2.8.0"
postcss.config.js
module.exports =
plugins: [
// ...
require("tailwindcss"),
require("autoprefixer")
// ...
]
;
我知道我缺少一个构建脚本,但我找不到有关如何添加它的正确文档。我尝试过的一切都错了。
【问题讨论】:
【参考方案1】:您忘记在脚本中添加 start 属性和文件名。
"scripts":
"start": "node your-script.js"
在你的情况下,在 package.json 中添加一个 start 将解决问题。
"name": "y",
"version": "1.0.0",
"description": "y",
"main": "index.js",
"scripts":
"start": "node mainjsfile.js",
"build-css": "tailwindcss build src/styles.css -o public/styles.css"
,
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies":
"autoprefixer": "^10.2.4",
"nodemon": "^2.0.7",
"postcss": "^8.2.6",
"tailwindcss": "^2.0.3"
,
"dependencies":
"alpinejs": "^2.8.0"
【讨论】:
以上是关于你如何使用 Tailwind.css 构建 npm?的主要内容,如果未能解决你的问题,请参考以下文章
Tailwind.css — 如何使用 Tailwind 实现 last-child?
Tailwind css 类未在 Storybook 构建中显示