{"id":21575467,"url":"https://github.com/rangle/serve-webpack-client","last_synced_at":"2025-06-13T15:04:08.218Z","repository":{"id":54143596,"uuid":"48928436","full_name":"rangle/serve-webpack-client","owner":"rangle","description":"Helper module for serving webpack-related client code from a nodejs server.","archived":false,"fork":false,"pushed_at":"2021-03-08T07:02:53.000Z","size":6,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-24T14:12:56.639Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rangle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-03T00:18:23.000Z","updated_at":"2017-03-04T16:26:13.000Z","dependencies_parsed_at":"2022-08-13T07:31:04.681Z","dependency_job_id":null,"html_url":"https://github.com/rangle/serve-webpack-client","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/rangle%2Fserve-webpack-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rangle%2Fserve-webpack-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rangle%2Fserve-webpack-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rangle%2Fserve-webpack-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rangle","download_url":"https://codeload.github.com/rangle/serve-webpack-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247867363,"owners_count":21009240,"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-24T12:13:22.296Z","updated_at":"2025-04-10T16:30:21.960Z","avatar_url":"https://github.com/rangle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# serve-webpack-client\n\nHelper module for serving webpack-related client code from a nodejs server.\n\n[Webpack](http://webpack.github.io) is a great tool. So is\n[Express](http://expressjs.com).\n\nHowever using them together took some thinking given that I typically:\n\n* serve single-page applications (e.g. in ReactJS or AngularJS)\n* want to use the HTML5 history API to avoid the ugly '#' in my URLs.\n* want to use an express server to serve up both the client and a backend REST API.\n* want the express server configured to handle deep-linking for my app's routes\n* want to serve the app from static files in production, but from Webpack's watcher\nwhen I'm in developer mode.\n\nThis module is the special sauce I need to do all this stuff at once.\n\n## Installation\n\nGet it from npm:\n\n```sh\nnpm install --save serve-webpack-client\n```\n\n## Code\n\nUse it like this (server.js):\n\n```javascript\nconst serveWebpackClient = require('serve-webpack-client');\n\nconst app = express();\n\n// configure your REST API routes here as normal.\n\n// Now set up the client to serve itself:\napp.use(serveWebpackClient({\n  distPath: path.join(__dirname, '/dist'), // Used in prod\n  indexFileName: 'index.html',\n  webpackConfig: require('/webpack.config') // Used for dev.\n}));\n\napp.listen(3000);\n```\n\n## Run in dev mode:\n\n```sh\nnodemon server.js\n```\n\nThis will monitor your server source code for changes and refresh; it will also\nuse [webpack-dev-middleware](https://www.npmjs.com/package/webpack-dev-middleware)\nto monitor your client assets and refresh.\n\nYour app will be served from `domain/index.html` or domain/your/arbitrary/path/index.html`\nto allow for deep linking to single-page app routes.\n\n## Run in prod mode:\n\n```sh\nwebpack -p # build your client to /dist as static files\n\nNODE_ENV=production node server.js\n```\n\nWhen `NODE_ENV === 'production'`, `webpack-dev-middleware` is not used.  Instead\nwe use `express.static` to serve whatever you previously built out to the `/dist`\nfolder.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frangle%2Fserve-webpack-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frangle%2Fserve-webpack-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frangle%2Fserve-webpack-client/lists"}