{"id":354,"date":"2022-06-26T20:45:58","date_gmt":"2022-06-26T11:45:58","guid":{"rendered":"https:\/\/hikki-reserve.com\/wordpress\/?p=354"},"modified":"2022-07-09T20:58:42","modified_gmt":"2022-07-09T11:58:42","slug":"how-to-include-webpack-at-first","status":"publish","type":"post","link":"https:\/\/hikki-reserve.com\/wordpress\/how-to-include-webpack-at-first\/","title":{"rendered":"Webpack\u306e\u5c0e\u5165\u65b9\u6cd5"},"content":{"rendered":"<p>\u666e\u6bb5\u306e\u4f5c\u696d\u3067Web\u5236\u4f5c\u3092\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u591a\u3044\u306e\u3067\u3001&#8221;Webpack V5&#8243;\u3068\u3044\u3046\u30e2\u30b8\u30e5\u30fc\u30eb\u30d0\u30f3\u30c9\u30e9\u30fc\u3092\u4f7f\u3063\u3066\u307f\u308b\u3053\u3068\u306b\u306a\u3063\u305f\u3002\u6700\u521d\u306f\u3001&#8221;Parcel V2&#8243;\u3092\u4f7f\u304a\u3046\u3068\u601d\u3063\u305f\u306e\u3060\u304c\u3001\u78ba\u304b\u306b\u304a\u624b\u8efd\u306b\u8a2d\u5b9a\u3057\u3066\u4f7f\u3046\u3053\u3068\u304c\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u306e\u3060\u3051\u3069\u3082\u3001\u30c8\u30e9\u30f3\u30b9\u30d1\u30a4\u30eb\uff08\u30b3\u30f3\u30d1\u30a4\u30eb\u7684\u306a\u30a4\u30e1\u30fc\u30b8\uff09\u3092\u3057\u305f\u3068\u3053\u308d\u3001PHP\u30b3\u30fc\u30c9\u304c\u3054\u3063\u305d\u308a\u53d6\u308a\u9664\u304b\u308c\u3066\u3044\u305f\u306e\u3067\u3001\u81ea\u5206\u304c\u4f7f\u3046\u30e1\u30e2\u3068\u3057\u3066Webpack\u306e\u5c0e\u5165\u624b\u9806\u3092\u8d70\u308a\u66f8\u304d\u3057\u3066\u304a\u304f\u3053\u3068\u306b\u3057\u305f\u3002<\/p>\n<h2>&#8220;Webpack V5&#8243;\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<h3>\u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4f5c\u6210<\/h3>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>[userdir$] mkdir {workdir}<\/code><\/pre>\n<\/div>\n<p>\u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3002\u4f5c\u6210\u3057\u305f\u3089\u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u79fb\u52d5\u3059\u308b\u306e\u3092\u5fd8\u308c\u305a\u306b\uff01<\/p>\n<h3>&#8220;npm init -y&#8221;\u3092\u5b9f\u884c<\/h3>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>[workdir$] npm init -y<\/code><\/pre>\n<\/div>\n<p>\u521d\u671f\u5316\u3055\u308c\u305f&#8221;package.json&#8221;\u3092\u4f5c\u6210\u3002<\/p>\n<h3>&#8220;npm install -D webpack webpack-cli&#8221;\u3092\u5b9f\u884c<\/h3>\n<div class=\"hcb_wrap\">\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>[workdir$] npm install -D webpack webpack-cli<\/code><\/pre>\n<\/div>\n<\/div>\n<p>\u3061\u3083\u3093\u3068\uff12\u3064\u3068\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3053\u3068\u3002\u7247\u65b9\u3067\u3082\u8db3\u308a\u306a\u3044\u3068\u30c0\u30e1\uff01<\/p>\n<h3>&#8220;npx webpack-cli init&#8221;\u3092\u5b9f\u884c<\/h3>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>[workdir$] npx webpack-cli init<\/code><\/pre>\n<\/div>\n<p>&#8220;npm&#8221;\u30b3\u30de\u30f3\u30c9\u3067\u306f\u7121\u304f\u3001&#8221;npx&#8221;\u3067\u3042\u308b\u3053\u3068\u306b\u6ce8\u610f\uff01<\/p>\n<h3>\u5bfe\u8a71\u5f62\u5f0f\u3067\u30bb\u30c3\u30c6\u30a3\u30f3\u30b0<\/h3>\n<p>\u7d50\u69cb\u8cea\u554f\u3055\u308c\u308b\u300210\u500b\u304f\u3089\u3044\u8cea\u554f\u3055\u308c\u308b\u3002\u3060\u3044\u305f\u3044[Y\/n]\u3067\u7b54\u3048\u308c\u3070\u826f\u3044\u3002<\/p>\n<h3>webpack.config.js \u306e\u81ea\u52d5\u751f\u6210\uff08\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\uff09<\/h3>\n<p>\u3059\u3079\u3066\u306e\u8cea\u554f\u306b\u7b54\u3048\u308b\u3068\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\uff08Webpack\u304c\u4f7f\u3048\u308b\u8a2d\u5b9a\uff09\u304c\u81ea\u52d5\u3067\u884c\u308f\u308c\u308b\u3002<br \/>\n&#8220;package.json&#8221;\u3092\u4e0a\u66f8\u304d\u3059\u308b\u304b\u3069\u3046\u304b\u805e\u304b\u308c\u308b\u6642\u306b6\u3064\u304f\u3089\u3044\u306e\u9078\u629e\u80a2\u304c\u51fa\u308b\u304c\u3001\u591a\u5206&#8221;a&#8221;\u3067\u826f\u3044\u3068\u601d\u3046\uff08\u3059\u3079\u3066\u4e0a\u66f8\u304d\uff09\u3002<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>\r\n\"scripts\": {\r\n  \"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\",\r\n  \"build\": \"webpack --mode=production --node-env=production --color\",\r\n  \"build:dev\": \"webpack --mode=development --color\",\r\n  \"build:prod\": \"webpack --mode=production --node-env=production --color\",\r\n  \"watch\": \"webpack --watch --color\",\r\n  \"serve\": \"webpack serve --mode=development --color\"\r\n},\r\n<\/code><\/pre>\n<\/div>\n<p>\u2191 \u500b\u4eba\u7684\u306a\u597d\u307f\u3067<code>\"--color\"<\/code>\uff08\u30ab\u30e9\u30fc\u30aa\u30d7\u30b7\u30e7\u30f3\uff09\u3092\u8ffd\u52a0\u3057\u3066\u3044\u308b\u304c\u4f7f\u3048\u308b\u30b3\u30de\u30f3\u30c9\u306f\u3053\u3093\u306a\u611f\u3058\u3002\u3002\u3002<\/p>\n<h3>webpack.config.js \u306e\u7de8\u96c6<\/h3>\n<p>\u6700\u5f8c\u306b\u3001\u6b21\u306e\u6587\u5b57\u5217\u3092\u8ffd\u52a0\u3002<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>{\r\n  ...... (\u7565)\r\n  watchOptions: {\r\n    ignored: \"\/node_modules\/\",\r\n  },\r\n};<\/code><\/pre>\n<\/div>\n<p>\u5909\u63db\u6642\u306b &#8220;node_modules&#8221;\u30c7\u30a3\u30ec\u30af\u30c8\u30ea \u3092\u7121\u8996\u3059\u308b\u3088\u3046\u306b\u306a\u308b\uff1f<\/p>\n<h2>\u8a2d\u5b9a\u304c\u81ea\u52d5\u751f\u6210\u3067\u304d\u305f<\/h2>\n<p>\u3061\u3083\u3093\u3068PHP\u30b3\u30fc\u30c9\u3082\u51fa\u529b\u3055\u308c\u3066\u3044\u308b\u3002\u3068\u308a\u3042\u3048\u305a\u3053\u308c\u3067\u3001&#8221;Parcel V2&#8243;\u307b\u3069\u3058\u3083\u306a\u3044\u304c\u5c0e\u5165\u624b\u9806\u304c\u30b7\u30f3\u30d7\u30eb\u306b\u306a\u3063\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u666e\u6bb5\u306e\u4f5c\u696d\u3067Web\u5236\u4f5c\u3092\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u591a\u3044\u306e\u3067\u3001&#8221;Webpack V5&#8243;\u3068\u3044\u3046\u30e2\u30b8\u30e5\u30fc\u30eb\u30d0\u30f3\u30c9\u30e9\u30fc\u3092\u4f7f\u3063\u3066\u307f\u308b\u3053\u3068\u306b\u306a\u3063\u305f\u3002\u6700\u521d\u306f\u3001&#8221;Parcel V2&#8243;\u3092\u4f7f\u304a\u3046\u3068\u601d\u3063\u305f\u306e&#8230;<\/p>\n","protected":false},"author":1,"featured_media":355,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75],"tags":[82,83],"class_list":["post-354","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web","tag-webpack","tag-webpack-config-js"],"_links":{"self":[{"href":"https:\/\/hikki-reserve.com\/wordpress\/wp-json\/wp\/v2\/posts\/354"}],"collection":[{"href":"https:\/\/hikki-reserve.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hikki-reserve.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hikki-reserve.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hikki-reserve.com\/wordpress\/wp-json\/wp\/v2\/comments?post=354"}],"version-history":[{"count":7,"href":"https:\/\/hikki-reserve.com\/wordpress\/wp-json\/wp\/v2\/posts\/354\/revisions"}],"predecessor-version":[{"id":379,"href":"https:\/\/hikki-reserve.com\/wordpress\/wp-json\/wp\/v2\/posts\/354\/revisions\/379"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hikki-reserve.com\/wordpress\/wp-json\/wp\/v2\/media\/355"}],"wp:attachment":[{"href":"https:\/\/hikki-reserve.com\/wordpress\/wp-json\/wp\/v2\/media?parent=354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hikki-reserve.com\/wordpress\/wp-json\/wp\/v2\/categories?post=354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hikki-reserve.com\/wordpress\/wp-json\/wp\/v2\/tags?post=354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}