{"id":21465398,"url":"https://github.com/jacobhsu/webpack-demo","last_synced_at":"2025-03-17T05:43:48.791Z","repository":{"id":31232392,"uuid":"127294899","full_name":"JacobHsu/webpack-demo","owner":"JacobHsu","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-04T01:26:05.000Z","size":1605,"stargazers_count":0,"open_issues_count":20,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-23T15:18:14.946Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JacobHsu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-29T13:25:08.000Z","updated_at":"2020-06-12T06:41:43.000Z","dependencies_parsed_at":"2023-01-14T18:36:31.465Z","dependency_job_id":null,"html_url":"https://github.com/JacobHsu/webpack-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobHsu%2Fwebpack-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobHsu%2Fwebpack-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobHsu%2Fwebpack-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobHsu%2Fwebpack-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JacobHsu","download_url":"https://codeload.github.com/JacobHsu/webpack-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243982141,"owners_count":20378605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-23T08:10:12.348Z","updated_at":"2025-03-17T05:43:48.773Z","avatar_url":"https://github.com/JacobHsu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webpack-demo\n\nWebpack [Getting Started](https://webpack.js.org/guides/getting-started/)\n\n使用 webpack 來管理這些腳本\n\n「源」代碼(/src) 書寫和編輯的代碼  \n「分發」代碼(/dist) 構建過程產生的代碼最小化和優化後的「輸出」目錄\n\n`npx webpack src/index.js --output dist/bundle.js`  \nThe `npx` command, which ships with `Node 8.2` or higher\n\n`npm run build`\n\n# sample\n\nWebpack 範例\n\n體驗一下 Webpack  \n教學：https://www.webpackjs.com/concepts/\n\n1. 安裝 webpack 相關套件\n2. 設置 webpack.config.js\n3. 建立 index.html 及 src 內的相關檔案\n4. 使用 [css loader](https://github.com/webpack-contrib/css-loader)\n5. [Sass loader](https://github.com/webpack-contrib/sass-loader)\n\n6. [web server](https://github.com/webpack/webpack-dev-server)\n\n[DevServer](https://webpack.js.org/configuration/dev-server/)\n\n## webpack-dev-server\n\nThe [webpack-dev-server](https://webpack.js.org/guides/development/#using-webpack-dev-server) provides you with a simple web server and the ability to use live reloading.\n\n`npm install --save-dev webpack-dev-server`\n\nwebpack.config.js\n\n```js\n  module.exports = {\n    mode: 'development',\n    entry: {\n      app: './src/index.js',\n      print: './src/print.js',\n    },\n    devtool: 'inline-source-map',\n+   devServer: {\n+     contentBase: './dist',\n+   },\n    plugins: [\n      new CleanWebpackPlugin({ cleanStaleWebpackAssets: false }),\n      new HtmlWebpackPlugin({\n        title: 'Development',\n      }),\n    ],\n    output: {\n      filename: '[name].bundle.js',\n      path: path.resolve(__dirname, 'dist'),\n    },\n  };\n```\n\nThis tells `webpack-dev-server` to serve the files from the dist directory on localhost:8080.\n\npackage.json\n\n```js\n\"scripts\": {\n    \"start\": \"webpack-dev-server --open\",\n},\n```\n\nnpm start\n\n[devServer.contentBase](https://webpack.js.org/configuration/dev-server/#devservercontentbase)\n\nUsage via the CLI\n\n```js\nwebpack-dev-server --content-base /dir\n\n\"start\": \"webpack-dev-server --content-base src --open --hot\",\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobhsu%2Fwebpack-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacobhsu%2Fwebpack-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobhsu%2Fwebpack-demo/lists"}