{"id":16573,"date":"2022-02-06T09:48:34","date_gmt":"2022-02-06T00:48:34","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=16573"},"modified":"2023-05-27T18:22:36","modified_gmt":"2023-05-27T09:22:36","slug":"%e3%80%90css%e3%80%91css%e3%82%92minify%e5%8c%96%e3%81%99%e3%82%8b%e3%81%ab%e3%81%af%e3%80%82","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=16573","title":{"rendered":"\u3010CSS\u3011POSTCSS\u306e\u30d3\u30eb\u30c9\u7d50\u679c\u3092minify\u5316\u3059\u308b\u306b\u306f\u3002"},"content":{"rendered":"<p>POSTCSS\u3092\u4f7f\u3048\u3070CSS\u306e\u30d3\u30eb\u30c9\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u672c\u756a\u74b0\u5883\u5411\u3051\u306bminify\u5316\u3059\u308b\u306b\u306f\u300ccssnano\u300d\u3068\u3044\u3046\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<pre class=\"lang:default decode:true\">npm i -D cssnano<\/pre>\n<h2>\u8a2d\u5b9a<\/h2>\n<h3>postcss.config.js<\/h3>\n<p>POSTCSS\u306ecssnano\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">module.exports = (ctx) =&gt; {\r\n  return {\r\n    plugins: {\r\n      tailwindcss: {},\r\n      autoprefixer: {},\r\n      cssnano: ctx.env === \"production\" ? {} : false,\r\n    },\r\n  };\r\n};\r\n<\/pre>\n<h3>package.json<\/h3>\n<p>dev\u304c\u958b\u767a\u74b0\u5883\u5411\u3051\u306e\u30d3\u30eb\u30c9\u3001build\u304c\u672c\u756a\u74b0\u5883\u5411\u3051\u306e\u30d3\u30eb\u30c9\u3092\u60f3\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">  \"scripts\": {\r\n    \"dev\": \"postcss style.css -o dist.css\",\r\n    \"build\": \"NODE_ENV=production postcss style.css -o dist.css\"\r\n  },<\/pre>\n<h2>\u30d3\u30eb\u30c9<\/h2>\n<h3>\u958b\u767a\u74b0\u5883\u5411\u3051\u30d3\u30eb\u30c9<\/h3>\n<p>POSTCSS\u306e\u8a2d\u5b9a\u3067\u958b\u767a\u6642\u306fminify\u5316\u3055\u305b\u3066\u3044\u306a\u3044\u306e\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u958b\u767a\u6642\u306fminify\u304c\u306a\u3044\u65b9\u304c\u30d3\u30eb\u30c9\u6642\u9593\u304c\u77ed\u304f\u306a\u308a\u307e\u3059\u3057\u3001\u8aad\u307f\u3084\u3059\u304f\u306a\u3063\u3066\u958b\u767a\u3057\u3084\u3059\u304f\u306a\u308b\u306e\u3067\u57fa\u672c\u7684\u306b\u306fminify\u5316\u3057\u306a\u3044\u65b9\u304c\u826f\u3044\u305f\u3081\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">npm run dev<\/pre>\n<h3>\u672c\u756a\u74b0\u5883\u5411\u3051\u30d3\u30eb\u30c9<\/h3>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30d3\u30eb\u30c9\u3092\u3057\u305f\u3089\u30d3\u30eb\u30c9\u7d50\u679c\u304cminify\u5316\u3055\u308c\u3066\u51fa\u529b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">npm run build<\/pre>\n<h2>CSS\u5727\u7e2e\u306e\u4ed6\u306e\u9078\u629e\u80a2<\/h2>\n<ul>\n<li>\u5727\u7e2e\u30b5\u30a4\u30c8\u3092\u4f7f\u3046\u3002<\/li>\n<li>vscode\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u3046\u3002<\/li>\n<\/ul>\n<p>\u30c7\u30b6\u30a4\u30ca\u30fc\u3055\u3093\u306a\u3069\u306e\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u74b0\u5883\u3092\u8003\u616e\u3057\u3066\u3001\u3044\u307e\u3060\u306b\u975enpm\u74b0\u5883\u306a\u3089\u30a2\u30ea\u304b\u3082\u3057\u308c\u306a\u3044\u3067\u3059\u3002<\/p>\n<h2>minify\u5316\u306e\u30e1\u30ea\u30c3\u30c8<\/h2>\n<h3>\u30da\u30fc\u30b8\u306e\u8868\u793a\u901f\u5ea6\u5411\u4e0a<\/h3>\n<p>\u7279\u306b\u30cd\u30c3\u30c8\u56de\u7dda\u304c\u5f31\u5f31\u306a\u74b0\u5883\u3067\u306f\u91cd\u8981\u3067\u3059\u3002\u30b3\u30f3\u30de\u4f55\u79d2\u306e\u8868\u793a\u901f\u5ea6\u306e\u9055\u3044\u304c\u30e6\u30fc\u30b6\u30fc\u306e\u96e2\u8131\u306b\u3064\u306a\u304c\u3063\u305f\u308a\u3057\u307e\u3059\u3002Google\u304c\u884c\u306a\u3063\u3066\u3044\u308b\u8a08\u6e2c\u30c4\u30fc\u30eb\u3067\u306fminify\u5316\u3059\u308b\u304b\u3057\u306a\u3044\u304b\u3067\u6570\u79d2\u7e2e\u307e\u308b\u30b5\u30a4\u30c8\u3082\u3042\u3063\u305f\u3088\u3046\u3067\u3059\u3002<\/p>\n<h3>\u30b5\u30fc\u30d0\u30fc\u306e\u5bb9\u91cf\u7bc0\u7d04<\/h3>\n<p>\u5c11\u3057\u3067\u3082\u7bc0\u7d04\u3057\u305f\u3044\u3067\u3059\u3002\u3069\u3093\u3069\u3093\u30b5\u30a4\u30c8\u306e\u30b3\u30f3\u30c6\u30f3\u30c4\u306f\u5897\u3048\u3066\u3044\u304f\u306e\u3067\u3067\u304d\u308b\u3060\u3051\u5c11\u306a\u3044\u65b9\u304c\u826f\u3044\u3067\u3059\u3002<\/p>\n<h3>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306e\u89e3\u8aad\u3092\u96e3\u3057\u304f\u3057\u76d7\u7528\u9632\u6b62<\/h3>\n<p>\u4eca\u306fdeveloper\u30c4\u30fc\u30eb\u304c\u4fbf\u5229\u3067\u6574\u5f62\u306a\u3069\u3082\u3067\u304d\u308b\u306e\u3067\u3042\u307e\u308a\u5927\u3057\u305f\u30e1\u30ea\u30c3\u30c8\u3067\u306f\u306a\u3044\u304b\u3082\u3067\u3059\u304c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"POSTCSS\u3092\u4f7f\u3048\u3070CSS\u306e\u30d3\u30eb\u30c9\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u672c\u756a\u74b0\u5883\u5411\u3051\u306bminify\u5316\u3059\u308b\u306b\u306f\u300ccssnano\u300d\u3068\u3044\u3046\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb npm i -D cssnano \u8a2d\u5b9a postcss.con [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[64],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/16573"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16573"}],"version-history":[{"count":7,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/16573\/revisions"}],"predecessor-version":[{"id":20132,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/16573\/revisions\/20132"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16573"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}