{"id":2528,"date":"2024-11-10T11:21:01","date_gmt":"2024-11-10T03:21:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2528\/"},"modified":"2024-11-10T11:21:01","modified_gmt":"2024-11-10T03:21:01","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8webpack%e6%89%93%e5%8c%85%e9%9d%9e%e5%85%a5%e5%8f%a3%e6%96%87%e4%bb%b6%e4%b8%ad%e7%9a%84-tailwind-css-%e6%a0%b7%e5%bc%8f%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2528\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528Webpack\u6253\u5305\u975e\u5165\u53e3\u6587\u4ef6\u4e2d\u7684 Tailwind CSS \u6837\u5f0f\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173078429796925.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528Webpack\u6253\u5305\u975e\u5165\u53e3\u6587\u4ef6\u4e2d\u7684 Tailwind CSS \u6837\u5f0f\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528Webpack\u6253\u5305\u975e\u5165\u53e3\u6587\u4ef6\u4e2d\u7684 Tailwind CSS \u6837\u5f0f\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u914d\u7f6ewebpack tlwind\u4ee5\u6253\u5305\u975e\u5165\u53e3\u6587\u4ef6\u4e2d\u7684\u6837\u5f0f<\/strong><\/p>\n<p>\u4e3a\u4e86\u5c06non-entry\u6587\u4ef6\u4e2d\u7684tailwindcss\u6837\u5f0f\u88ab\u6253\u5305\u5230\u65b0\u7684css\u6587\u4ef6\uff0c\u9700\u8981\u5bf9webpack tailwindcss\u7684\u914d\u7f6e\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<p>\u5728tailwind.config.js\u6587\u4ef6\u4e2d\uff0c\u65b0\u589epurge\u914d\u7f6e\u9879\uff0c\u5e76\u6dfb\u52a0\u9700\u8981\u88ab\u89e3\u6790\u7684\u6587\u4ef6\u8def\u5f84\u3002\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>module.exports = {\n  purge: ['src\/*.html','src\/base\/*.html'],\n  darkMode: false, \/\/ or 'media' or 'class'\n  theme: {\n      extend: {},\n  },\n  variants: {\n      extend: {},\n  },\n  plugins: [],\n};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u6837\u4e00\u6765\uff0c\u7d22\u5f15\u7684html\u6587\u4ef6\u53ca\u5176\u4e2d\u5f15\u7528\u7684header.html\u6587\u4ef6\u4e2d\u7684tailwindcss\u7c7b\u540d\u5c31\u53ef\u4ee5\u88ab\u6b63\u786e\u6253\u5305\u5230css\u6587\u4ef6\u4e2d\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528Webpack\u6253\u5305\u975e\u5165\u53e3\u6587\u4ef6\u4e2d\u7684 Tlwind CSS \u6837\u5f0f\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u914d\u7f6ewebpack tlwind\u4ee5\u6253\u5305\u975e\u5165\u53e3\u6587\u4ef6\u4e2d\u7684\u6837\u5f0f \u4e3a\u4e86\u5c06non-entry\u6587\u4ef6\u4e2d\u7684tailwindcss\u6837\u5f0f\u88ab\u6253\u5305\u5230\u65b0\u7684css\u6587\u4ef6\uff0c\u9700\u8981\u5bf9webpack tailwindcss\u7684\u914d\u7f6e\u8fdb\u884c\u4fee\u6539\u3002 \u5728tailwind.config.js\u6587\u4ef6\u4e2d\uff0c\u65b0\u589epurge\u914d\u7f6e\u9879\uff0c\u5e76\u6dfb\u52a0\u9700\u8981\u88ab\u89e3\u6790\u7684\u6587\u4ef6\u8def\u5f84\u3002\u5982\u4e0b\u6240\u793a\uff1a module.exports = { purge: [&#8216;src\/*.html&#8217;,&#8217;src\/base\/*.html&#8217;], darkMode: false, \/\/ or &#8216;media&#8217; or &#8216;class&#8217; theme: { extend: {}, }, variants: { extend: {}, }, plugins: [], }; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u6837\u4e00\u6765\uff0c\u7d22\u5f15\u7684html\u6587\u4ef6\u53ca\u5176\u4e2d\u5f15\u7528\u7684header.html\u6587\u4ef6\u4e2d\u7684tailwindcss\u7c7b\u540d\u5c31\u53ef\u4ee5\u88ab\u6b63\u786e\u6253\u5305\u5230css\u6587\u4ef6\u4e2d\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528Webpack\u6253\u5305\u975e\u5165\u53e3\u6587\u4ef6\u4e2d\u7684 Tlwind CSS \u6837\u5f0f\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-2528","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=2528"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2528\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}