{"id":3658,"date":"2019-05-11T01:49:39","date_gmt":"2019-05-10T16:49:39","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=3658"},"modified":"2019-05-11T01:49:39","modified_gmt":"2019-05-10T16:49:39","slug":"webpack%e3%81%a7npm%e7%94%a8%e3%81%ab%e7%8b%ac%e8%87%aa%e3%83%91%e3%83%83%e3%82%b1%e3%83%bc%e3%82%b8%e3%82%92%e3%81%a4%e3%81%8f%e3%82%8b%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=3658","title":{"rendered":"webpack\u3067npm\u7528\u306b\u72ec\u81ea\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u3064\u304f\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u79c1\u306f\u4ee5\u524d\u304b\u3089\u4f55\u5ea6\u3082\u958b\u767a\u304c\u5fc5\u8981\u306b\u306a\u308b\u6a5f\u80fd\u3084\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u30d1\u30c3\u30b1\u30fc\u30b8\u5316\u3057\u3066\u6b21\u56de\u304b\u3089\u958b\u767a\u52b9\u7387\u3092\u4e0a\u3052\u308b\u3088\u3046\u306b\u5fc3\u639b\u3051\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u73fe\u5728<a href=\"https:\/\/github.com\/SUKOHI?tab=repositories\">\u79c1\u306eGitHub\u30a2\u30ab\u30a6\u30f3\u30c8<\/a>\u306b\u306f150\u3092\u8d85\u3048\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u5b58\u5728\u3057\u3066\u3044\u3066\u3001\u3044\u308f\u3070\u300c\u904e\u53bb\u306e\u79c1\u300d\u304c\u73fe\u5728\u306e\u958b\u767a\u3092\u624b\u4f1d\u3063\u3066\u304f\u308c\u3066\u3044\u308b\u72b6\u6cc1\u3067\u3059\ud83d\ude0a\u2728<\/p>\n<p>\u3057\u304b\u3057\u3001\u305d\u3046\u306f\u3044\u3063\u3066\u3082\u5168\u3066\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u6c38\u9060\u306b\u5229\u7528\u3067\u304d\u308b\u304b\u3068\u3044\u3063\u305f\u3089\u305d\u3046\u3067\u306f\u306a\u304f\u3001\u958b\u767a\u74b0\u5883\u306e\u5909\u9077\u306b\u3088\u3063\u3066\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u4e00\u90e8\u306b\u5909\u66f4\u3092\u52a0\u3048\u308b\u5fc5\u8981\u304c\u3067\u3066\u304d\u305f\u308a\u3057\u3066\u3044\u307e\u3059\u3002\u305d\u3057\u3066\u305d\u306e\u4e2d\u3067\u7279\u306b\u91cd\u8981\u306a\u306e\u304c\u3001<strong>webpack\u3078\u306e\u79fb\u884c<\/strong>\u3067\u3059\u3002<\/p>\n<p>\u4ee5\u524d\u79c1\u306f<code>bower<\/code>\u3068\u3044\u3046<code>twitte<\/code>\u793e\u304c\u958b\u767a\u3057\u3066\u3044\u305f\u30d1\u30c3\u30b1\u30fc\u30b8\u30de\u30cd\u30fc\u30b8\u30e3\u3092\u4f7f\u3063\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u73fe\u5728\u3067\u306f\u3059\u3067\u306b\u975e\u63a8\u5968\u3068\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u305f\u3081<code>Laravel<\/code>\u304c\u6a19\u6e96\u3067\u5229\u7528\u3057\u3066\u3044\u308b<code>npm<\/code>\u3078\u5909\u66f4\u3057\u305f\u3068\u3044\u3046\u7d4c\u7def\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001<code>npm<\/code>\u3092\u5229\u7528\u3059\u308b\u3068\u30d0\u30f3\u30c9\u30eb\uff08\u5168\u30b3\u30fc\u30c9\u3092\u3072\u3068\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u3059\u308b\uff09\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u3001\u901a\u5e38\u306e\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u3057\u307e\u3046\u3068<code>undefined<\/code>\u3068\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3059\u3002<\/p>\n<pre>\/\/ my-package.js\r\n\r\nvar myPackage = {\r\n    testFunction() {\r\n\r\n        return 'xxx';\r\n\r\n    },\r\n    testString: 'yyy'\r\n};<\/pre>\n<pre>\/\/ \u305d\u3057\u3066\u3001\u30d0\u30f3\u30c9\u30eb\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3082\r\nconsole.log(myPackage); \/\/ undefined\u306b\u306a\u308b\ud83d\ude05<\/pre>\n<p>\u305d\u3053\u3067\uff01<br \/>\n\u4eca\u56de\u306fJavaScript\u306e\u72ec\u81ea\u30d1\u30c3\u30b1\u30fc\u30b8\u3092 webpack \u5411\u3051\u306b\u958b\u767a\u3059\u308b\u65b9\u6cd5\u3092\u304a\u5c4a\u3051\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3405 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_18.png\" alt=\"\" width=\"310\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_18.png 310w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_18-291x300.png 291w\" sizes=\"auto, (max-width: 310px) 100vw, 310px\" \/><\/p>\n<h1>\u307e\u305a\u306f\u624b\u9806\u304b\u3089<\/h1>\n<p>\u307e\u305a\u72ec\u81ea\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u3064\u304f\u308b\u624b\u9806\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<br \/>\n\uff08\u3059\u3067\u306b\u3054\u5b58\u77e5\u306e\u65b9\u306f\u8aad\u307f\u98db\u3070\u3057\u3066\u304f\u3060\u3055\u3044\uff09<\/p>\n<ol>\n<li>\u5143\u306b\u306a\u308b\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u3064\u304f\u308b<\/li>\n<li>webpack\u3067\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30d6\u30e9\u30a6\u30b6\u306b\u5411\u3051\u306b\u7d71\u5408\u3001\u6539\u5909<\/li>\n<li>\u65b0\u3057\u3044JavaScript\u30d5\u30a1\u30a4\u30eb\u3092\u51fa\u529b\u3059\u308b<\/li>\n<\/ol>\n<p>\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\n\u3084\u306f\u308a\uff08\u8a2d\u5b9a\u3059\u308c\u3070\u3067\u3059\u304c\uff09ES6\u3092\u4f7f\u3063\u3066\u30b3\u30fc\u30c9\u3092\u66f8\u3051\u305f\u308a\u3059\u308b\u306e\u3067IE 11\u7528\u306b\u53e4\u3044\u8a18\u8ff0\u3092\u3059\u308b\u5fc5\u8981\u304c\u306a\u304f\u306a\u308b\u306e\u306f\u5927\u304d\u3044\u3067\u3059\u306d\u3002<\/p>\n<p>\u307e\u305f\u3001\u3072\u3068\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u307e\u3068\u3081\u3066\u304f\u308c\u305f\u308a\u3001\u4f59\u5206\u306a\u6539\u884c\u3084\u7a7a\u767d\u3092\u9664\u53bb\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u8868\u793a\u304c\u65e9\u304f\u306a\u308a\u3001\u8a2a\u554f\u30e6\u30fc\u30b6\u30fc\u5074\u3078\u306e\u30e1\u30ea\u30c3\u30c8\u3082\u5927\u304d\u3044\u3068\u3044\u3063\u3066\u3044\u3044\u3067\u3057\u3087\u3046\uff01<\/p>\n<h1>\u74b0\u5883\u3092\u6574\u3048\u308b<\/h1>\n<p>\u524d\u63d0\u3068\u3057\u3066<code>webpack<\/code>\u306f\u3001<code>npm<\/code>\u304c\u5fc5\u8981\u3067\u3059\u306e\u3067\u4ee5\u4e0b\u306e\u624b\u9806\u3067<code>npm<\/code>\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<ol>\n<li>node.js\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\uff08<a href=\"https:\/\/nodejs.org\/ja\/download\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u516c\u5f0f\u30b5\u30a4\u30c8<\/a>\uff09<\/li>\n<li>npm\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\uff08<code>npm install npm@latest -g<\/code>\uff09<\/li>\n<\/ol>\n<p>\u3055\u3041\u3001\u3053\u308c\u3067\u958b\u767a\u306e\u305f\u3081\u306e\u74b0\u5883\u304c\u6574\u3044\u307e\u3057\u305f\uff01<\/p>\n<h1>\u72ec\u81ea\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f5c\u308b<\/h1>\n<h2>\u3084\u308a\u305f\u3044\u3053\u3068<\/h2>\n<p>\u72ec\u81ea\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f5c\u308b\u3068\u3044\u3063\u3066\u3082\u3044\u308d\u3093\u306a\u30b4\u30fc\u30eb\u304c\u3042\u308b\u3068\u601d\u3046\u306e\u3067\u3001\u306f\u3058\u3081\u306b\u4f55\u304c\u3057\u305f\u3044\u304b\u3092\u307e\u3068\u3081\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<ul>\n<li>ES6\u3067\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3051\u3069\u3001IE 11\u306b\u306f\u5bfe\u5fdc\u3055\u305b\u308b<\/li>\n<li>\u30d0\u30f3\u30c9\u30eb\u3055\u308c\u305f\u30b3\u30fc\u30c9\u306f\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u3092\u5727\u7e2e\uff08\u4f59\u5206\u306a\u6539\u884c\u3084\u7a7a\u767d\u3092\u9664\u53bb\uff09\u3059\u308b<\/li>\n<li>\u4f5c\u6210\u3057\u305f\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30b0\u30ed\u30fc\u30d0\u30eb\u3067\u547c\u3073\u51fa\u305b\u308b\uff08\u5192\u982d\u3067\u66f8\u3044\u305f\u5185\u5bb9\u306e\u89e3\u6c7a\uff09<\/li>\n<\/ul>\n<h2>\u5b9f\u969b\u306b\u4f5c\u3063\u3066\u307f\u3088\u3046<\/h2>\n<p>\u3067\u306f\u3001\u3053\u3053\u304b\u3089\u5b9f\u969b\u306b\u72ec\u81ea\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<br \/>\n\u4eca\u56de\u30c6\u30b9\u30c8\u3067\u4f5c\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u540d\u306f<code>hello<\/code>\u3067\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f\u3069\u3053\u3067\u3082\u3044\u3044\u306e\u3067\u597d\u304d\u306a\u5834\u6240\u306b\u5c02\u7528\u306e\u30d5\u30a9\u30eb\u30c0\u3092\u3064\u304f\u308a\u307e\u3059\u3002\uff08Laravel\u306e\u5834\u5408\u306f\u30c6\u30b9\u30c8\u3057\u3084\u3059\u3044\u306e\u3067<code>public<\/code>\u4ee5\u4e0b\u304c\u3044\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3662\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/05\/Screenshot-from-2019-05-10-18-46-04.png\" alt=\"\" width=\"302\" height=\"45\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/05\/Screenshot-from-2019-05-10-18-46-04.png 302w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/05\/Screenshot-from-2019-05-10-18-46-04-300x45.png 300w\" sizes=\"auto, (max-width: 302px) 100vw, 302px\" \/><\/p>\n<p>\u305d\u3057\u3066\u3001\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067<code>hello<\/code>\u30d5\u30a9\u30eb\u30c0\u3078\u79fb\u52d5\u3057\u3066\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre><strong><span class=\"token function\">npm<\/span> init -y<\/strong><\/pre>\n<p>\u3059\u308b\u3068<code>hello<\/code>\u30d5\u30a9\u30eb\u30c0\u5185\u306b<code>package.json<\/code>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5fc5\u8981\u306a\u8a18\u8ff0\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002\uff08\u592a\u5b57\u304c\u8ffd\u52a0\u3057\u305f\u90e8\u5206\u3067\u3059\uff09<\/p>\n<pre>{\r\n  \"name\": \"hello\",\r\n  \"version\": \"1.0.0\",\r\n  \"description\": \"\",\r\n  \"main\": \"hello.js\",\r\n  \"scripts\": {\r\n    \"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\",\r\n    <strong>\"dev\": \"webpack --mode development\",<\/strong>\r\n<strong>    \"production\": \"webpack --mode production\"<\/strong>\r\n  },\r\n  \"keywords\": [],\r\n  \"author\": \"\",\r\n  \"license\": \"ISC\"\r\n}<\/pre>\n<p>\u203b \u3061\u306a\u307f\u306b\u300c<strong>dev<\/strong>\u300d\u300c<strong>production<\/strong>\u300d\u306fLaravel\u306b\u5408\u308f\u305b\u305f\u3082\u306e\u3067\u3059\u304c\u81ea\u7531\u306b\u6c7a\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u305d\u3057\u3066\u3001\u3053\u306e\u5834\u5408<code>npm run dev<\/code>\u3068<code>npm run production<\/code>\u304c\u5b9f\u884c\u30b3\u30de\u30f3\u30c9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u5fc5\u8981\u306anpm\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002\uff08\u4eca\u56de\u5fc5\u8981\u306b\u306a\u308b\u306e\u306f\u3001\uff14\u3064\u3067\u3059\u304c\u3001\u304a\u597d\u307f\u3067\u4ed6\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u5165\u308c\u305f\u3044\u5834\u5408\u3082\u3053\u3053\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\uff09<\/p>\n<pre><strong>npm i @babel\/preset-env babel-loader webpack webpack-cli --save-dev<\/strong><\/pre>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5b8c\u4e86\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b<code>node_modules<\/code>\u3068\u3044\u3046\u30d5\u30a9\u30eb\u30c0\u304c\u4f5c\u6210\u3055\u308c\u3001\u3053\u306e\u4e2d\u306b\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u683c\u7d0d\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3663\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/05\/Screenshot-from-2019-05-10-18-51-54.png\" alt=\"\" width=\"296\" height=\"115\" \/><\/p>\n<p>\u7d9a\u3044\u3066<code>webpack<\/code>\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb<code>webpack.config.js<\/code>\u3092\u4f5c\u3063\u3066\u3069\u3046\u3044\u3046\u98a8\u306b\u30d5\u30a1\u30a4\u30eb\u3092\u30d0\u30f3\u30c9\u30eb\uff08\u7d71\u5408\uff09\uff06\u30c8\u30e9\u30f3\u30b9\u30d1\u30a4\u30eb\uff08\u6539\u5909\uff09\u3059\u308b\u304b\u3092\u6c7a\u3081\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3664\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/05\/Screenshot-from-2019-05-10-19-01-04.png\" alt=\"\" width=\"291\" height=\"131\" \/><\/p>\n<p>\u4e2d\u8eab\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>const path = require('path');\r\n\r\nmodule.exports = {\r\n    <strong>entry: '.\/src\/hello.js', \/\/ \u3053\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u5143\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/strong>\r\n    output: {\r\n        <strong>filename: 'hello.js', \/\/ \u5b9f\u884c\u5f8c\u306e\u30d5\u30a1\u30a4\u30eb\u540d\r\n        path: path.resolve(__dirname, 'dist'), \/\/ \u7d76\u5bfe\u30d1\u30b9\u3067\u306a\u3044\u3068\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u306e\u3067\u3053\u306e\u8a18\u8ff0\u306b\u3057\u3066\u307e\u3059\r\n        library: 'hello', \/\/ hello\u3068\u3044\u3046\u5909\u6570\u3067\u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\r\n        libraryTarget: 'umd' \/\/ Laravel Mix\u3067\u5229\u7528\u3059\u308b\u306a\u3089\u5fc5\u8981<\/strong>\r\n    },\r\n    module: {\r\n        rules: [\r\n            {\r\n                test: \/\\.js$\/,\r\n                exclude: \/node_modules\/,\r\n                use: {\r\n                    loader: 'babel-loader',\r\n                    options: {\r\n                        presets: [\r\n                            <strong>\"@babel\/preset-env\" \/\/ IE\u306b\u5bfe\u5fdc\u3055\u305b\u308b\uff08\u3064\u307e\u308a\u53e4\u3044\u30b3\u30fc\u30c9\u306b\u5909\u63db\u3059\u308b\uff09<\/strong>\r\n                        ]\r\n                    }\r\n                }\r\n            }\r\n        ]\r\n    }\r\n};<\/pre>\n<p>\u3064\u307e\u308a\u5185\u5bb9\u3068\u3057\u3066\u306f\u3001<\/p>\n<p><strong><code>src\/hello.js<\/code>\u3092IE11\u306b\u5bfe\u5fdc\u3067\u304d\u308b\u30b3\u30fc\u30c9\u306b\u3057\u3001\u3055\u3089\u306b\u4f59\u5206\u306a\u6539\u884c\u3084\u7a7a\u767d\u3092\u9664\u53bb\u3057\u3066<code>dist\/hello.js<\/code>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b<\/strong><\/p>\n<p>\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001<code>src<\/code>\u30d5\u30a9\u30eb\u30c0\u3068<code>dist<\/code>\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u3063\u3066\u5143\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3068\u306a\u308b<code>src\/hello.js<\/code>\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3665\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/05\/Screenshot-from-2019-05-10-19-09-10.png\" alt=\"\" width=\"271\" height=\"201\" \/><\/p>\n<p>\u4eca\u56de\u306f\u30c6\u30b9\u30c8\u3067\u3059\u306e\u3067\u3001\u6b21\u306e\u3088\u3046\u306a\u30b7\u30f3\u30d7\u30eb\u306a\u30b3\u30fc\u30c9\u306b\u3057\u307e\u3059\u3002\uff08\u203b \u3053\u306e\u30b3\u30fc\u30c9\u81ea\u4f53\u306fIE11\u3067\u306f\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u300cES6\u300d\u5f62\u5f0f\u3067\u3042\u308b\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\uff09<\/p>\n<pre>const hello = {\r\n    japanese() {\r\n\r\n        return '\u304a\u306f\u3088\u3046\u3054\u3056\u3044\u307e\u3059\uff01';\r\n\r\n    }\r\n};\r\n\r\nmodule.exports = hello;<\/pre>\n<p>\u3067\u306f\u3001\u3053\u306e\u72b6\u614b\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u30d0\u30f3\u30c9\u30eb\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\uff01<\/p>\n<pre><strong>npm run dev<\/strong><\/pre>\n<p>\u3046\u307e\u304f\u3044\u3051\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b<code>dist<\/code>\u30d5\u30a9\u30eb\u30c0\u306b<code>hello.js<\/code>\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3666\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/05\/Screenshot-from-2019-05-10-19-12-49.png\" alt=\"\" width=\"275\" height=\"200\" \/><\/p>\n<p>\u3067\u306f\u3001\u5b9f\u884c\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u306e\u3067<code>tests\/index.html<\/code>\u3092\u4f5c\u3063\u3066\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3667\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/05\/Screenshot-from-2019-05-10-19-36-06.png\" alt=\"\" width=\"271\" height=\"267\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/05\/Screenshot-from-2019-05-10-19-36-06.png 271w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/05\/Screenshot-from-2019-05-10-19-36-06-100x100.png 100w\" sizes=\"auto, (max-width: 271px) 100vw, 271px\" \/><\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u8eab\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;!doctype html&gt;\r\n&lt;html&gt;\r\n&lt;body&gt;\r\n<strong>&lt;script src=\"..\/dist\/hello.js\" charset=\"utf8\"&gt;&lt;\/script&gt;<\/strong>\r\n&lt;script&gt;\r\n\r\n    <strong>console.log(hello.japanese());<\/strong>\r\n\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u305d\u3057\u3066\u3001\u30d6\u30e9\u30a6\u30b6\u3067\u5b9f\u884c\u3057\u3066\u307f\u308b\u3068\u3046\u307e\u304f\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\uff08\u4e0a\u304cGoogle Chrome\u3001\u4e0b\u304cIE 11\u3067\u3059\u3002\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3668\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/05\/Screenshot-from-2019-05-10-19-37-15.png\" alt=\"\" width=\"275\" height=\"105\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3669\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/05\/Screenshot-from-2019-05-10-19-40-55.png\" alt=\"\" width=\"347\" height=\"123\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/05\/Screenshot-from-2019-05-10-19-40-55.png 347w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/05\/Screenshot-from-2019-05-10-19-40-55-300x106.png 300w\" sizes=\"auto, (max-width: 347px) 100vw, 347px\" \/><\/p>\n<p>\u306a\u304a\u3001\u73fe\u5728\u306e\u72b6\u614b\u3067\u306f\u307e\u3060<code>dist\/hello.js<\/code>\u306f\u30b5\u30a4\u30ba\u5727\u7e2e\uff08\u4f59\u5206\u306a\u6539\u884c\u3084\u7a7a\u767d\u3092\u9664\u53bb\uff09\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u30b5\u30a4\u30ba\u5727\u7e2e\u3092\u5b9f\u884c\u3059\u308b\u5834\u5408\u306f<code>production<\/code>\u306e\u65b9\u3092\u4f7f\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>npm run production<\/strong><\/pre>\n<p>\u203b \u3064\u307e\u308a\u3001\u958b\u767a\u9014\u4e2d\u306f\u5185\u5bb9\u3092\u78ba\u8a8d\u3057\u3084\u3059\u3044\u3088\u3046\u306b\u300c<strong>dev\u30e2\u30fc\u30c9<\/strong>\u300d\u3092\u4f7f\u3044\u3001\u5b8c\u6210\u3057\u305f\u3089\u300c<strong>production\u30e2\u30fc\u30c9<\/strong>\u300d\u3092\u4f7f\u3046\u3068\u3044\u3046\u306e\u304c\u901a\u5e38\u306e\u6d41\u308c\u306b\u306a\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u4ee5\u4e0a\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\uff01<\/p>\n<p>\u203b \u306a\u304a\u3001\u3053\u306e\u9593\u516c\u958b\u3057\u305f\u8a18\u4e8b<a href=\"https:\/\/blog.capilano-fw.com\/?p=3621\">\u3010JavaScript\u3011\u65e5\u4ed8\u3084\u90fd\u9053\u5e9c\u770c\u3001\u901a\u8ca8\u306a\u3069\u65e5\u672c\u95a2\u9023\u306e\u30c7\u30fc\u30bf\u3092\u6271\u3046wafujs\u3092\u516c\u958b\u3057\u307e\u3057\u305f\uff01<\/a>\u3067\u7d39\u4ecb\u3057\u305f<a href=\"https:\/\/github.com\/SUKOHI\/wafujs\" target=\"_blank\" rel=\"noopener noreferrer\">wafujs<\/a>\u3082\u4eca\u56de\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u4f7f\u3063\u3066webpack\u5bfe\u5fdc\u3057\u305f\u306e\u3067\u826f\u304b\u3063\u305f\u3089\u305c\u3072\u4f7f\u3063\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u4eca\u56de\u306f <code>webpack<\/code> \u3067\u72ec\u81ea\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f5c\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u79c1\u306f\u305f\u304f\u3055\u3093\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u7ba1\u7406\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u306e\u3067\u3001<code>babel<\/code>\u306a\u3069\u306e<code>npm<\/code>\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092<code>-g<\/code>\u3067\u30b0\u30ed\u30fc\u30d0\u30eb\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u307e\u3057\u305f\u304c\u3001\u30d1\u30b9\u304c\u5408\u3063\u3066\u3044\u306a\u3044\u305f\u3081\u3046\u307e\u304f\u3044\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<p>\u305d\u306e\u5f8c\u3001\u89e3\u6c7a\u7b56\u3092\uff12\u3064\u307b\u3069\u898b\u3064\u3051\u306f\u3057\u305f\u3082\u306e\u306e\u300c\u3046\u30fc\u3093\u3001\u305d\u308c\u3060\u3063\u305f\u3089\u30ed\u30fc\u30ab\u30eb\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u308f\u30fc\ud83d\ude05\u300d\u3068\u3044\u3046\u72b6\u6cc1\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u306a\u306e\u3067\u3001\u3053\u306e\u90e8\u5206\u306b\u95a2\u3057\u3066\u306f\u4eca\u5f8c\u3082\u3082\u3063\u3068\u3044\u3044\u958b\u767a\u74b0\u5883\u3092\u63a2\u3063\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\uff08\u77e5\u3063\u3066\u305f\u3089\u305c\u3072\u6559\u3048\u3066\u304f\u3060\u3055\u3044\uff01\uff09<\/p>\n<p>\u305d\u3057\u3066\u3001\u6700\u5f8c\u306b\u9014\u4e2d\u3067\u4f5c\u6210\u3057\u305f<code>package.json<\/code>\u306e\u5909\u66f4\u4f8b\u3092\u304a\u307e\u3051\u3068\u3057\u3066\u3064\u3051\u3066\u304a\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\uff08\u592a\u5b57\u304c\u5909\u66f4\u7b87\u6240\uff09<\/p>\n<pre>{\r\n  \"name\": \"hello\",\r\n  \"version\": \"1.0.0\",\r\n  \"description\": <strong>\"A JavaScript package that allows you to try webpack.\"<\/strong>,\r\n  \"main\": \"hello.js\",\r\n  \"scripts\": {\r\n    \"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\",\r\n    \"dev\": \"webpack --mode development\",\r\n    \"production\": \"webpack --mode production\"\r\n  },\r\n  \"keywords\": [<strong>\"test\"<\/strong>],\r\n  \"author\": <strong>\"Sukohi Kuhoh\"<\/strong>,\r\n  \"license\": <strong>\"MIT\"<\/strong>,\r\n  \"devDependencies\": {\r\n    \"@babel\/preset-env\": \"^7.4.4\",\r\n    \"babel-loader\": \"^8.0.5\",\r\n    \"webpack\": \"^4.31.0\",\r\n    \"webpack-cli\": \"^3.3.2\"\r\n  }\r\n}<\/pre>\n<p>\u7686\u3055\u3093\u306e\u304a\u5f79\u306b\u305f\u3066\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\uff01<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1785 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/15-2.png\" alt=\"\" width=\"226\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/15-2.png 226w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/15-2-212x300.png 212w\" sizes=\"auto, (max-width: 226px) 100vw, 226px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u79c1\u306f\u4ee5\u524d\u304b\u3089\u4f55\u5ea6\u3082\u958b\u767a\u304c\u5fc5\u8981\u306b\u306a\u308b\u6a5f\u80fd\u3084\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u30d1\u30c3\u30b1\u30fc\u30b8\u5316\u3057\u3066\u6b21\u56de\u304b\u3089\u958b\u767a\u52b9\u7387\u3092\u4e0a\u3052\u308b\u3088\u3046\u306b\u5fc3\u639b\u3051\u3066\u3044\u307e\u3059\u3002 \u305d\u306e\u305f\u3081\u3001\u73fe\u5728\u79c1\u306eGitHub &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=3658\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;webpack\u3067npm\u7528\u306b\u72ec\u81ea\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u3064\u304f\u308b\u65b9\u6cd5&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":3673,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,2],"tags":[116,144],"class_list":["post-3658","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","category-2","tag-npm","tag-webpack"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/3658","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3658"}],"version-history":[{"count":6,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/3658\/revisions"}],"predecessor-version":[{"id":3672,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/3658\/revisions\/3672"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/3673"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}