{"id":13715379,"url":"https://github.com/easy-team/egg-webpack","last_synced_at":"2025-12-30T01:06:10.969Z","repository":{"id":20280053,"uuid":"89332275","full_name":"easy-team/egg-webpack","owner":"easy-team","description":"Egg Webpack Dev Server Plugin, Support Memory File and Hot-Reload","archived":false,"fork":false,"pushed_at":"2022-02-12T06:05:51.000Z","size":137,"stargazers_count":68,"open_issues_count":5,"forks_count":16,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-29T01:51:25.105Z","etag":null,"topics":["egg","hot-reload","memory-fs","webpack-dev-middleware","webpack-dev-server","webpack-hot-middleware","wepback"],"latest_commit_sha":null,"homepage":"https://easyjs.cn","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/easy-team.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-25T07:44:08.000Z","updated_at":"2023-11-28T13:33:48.000Z","dependencies_parsed_at":"2022-08-03T00:31:08.868Z","dependency_job_id":null,"html_url":"https://github.com/easy-team/egg-webpack","commit_stats":null,"previous_names":["hubcarl/egg-webpack"],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easy-team%2Fegg-webpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easy-team%2Fegg-webpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easy-team%2Fegg-webpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easy-team%2Fegg-webpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/easy-team","download_url":"https://codeload.github.com/easy-team/egg-webpack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252813643,"owners_count":21808362,"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":["egg","hot-reload","memory-fs","webpack-dev-middleware","webpack-dev-server","webpack-hot-middleware","wepback"],"created_at":"2024-08-03T00:00:58.319Z","updated_at":"2025-12-30T01:06:10.931Z","avatar_url":"https://github.com/easy-team.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# egg-webpack\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/egg-webpack.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/egg-webpack\n[travis-image]: https://img.shields.io/travis/hubcarl/egg-webpack.svg?style=flat-square\n[travis-url]: https://travis-ci.org/hubcarl/egg-webpack\n[codecov-image]: https://img.shields.io/codecov/c/github/hubcarl/egg-webpack.svg?style=flat-square\n[codecov-url]: https://codecov.io/github/hubcarl/egg-webpack?branch=master\n[david-image]: https://img.shields.io/david/hubcarl/egg-webpack.svg?style=flat-square\n[david-url]: https://david-dm.org/hubcarl/egg-webpack\n[snyk-image]: https://snyk.io/test/npm/egg-webpack/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/egg-webpack\n[download-image]: https://img.shields.io/npm/dm/egg-webpack.svg?style=flat-square\n[download-url]: https://npmjs.org/package/egg-webpack\n\nWebpack dev server plugin for egg, support read file in memory and hot reload. [More Detail](http://hubcarl.github.io/blog/2017/04/15/egg-webpack/)\n\n## Version\n\n- egg-webpack ^5.x.x \u003e webpack 5.x.x\n- egg-webpack ^4.x.x \u003e webpack 4.x.x\n- egg-webpack ^3.x.x \u003e webpack 3.x.x\n\n## Install\n\n```bash\nnpm i egg-webpack --save\n```\n\n## Usage\n\n```js\n// {app_root}/config/plugin.js\nexports.webpack = {\n  enable: true,\n  package: 'egg-webpack',\n};\n```\n\n## Configuration\n\n**support native webpack config and easywebpack webpack config**\n\n```js\n// {app_root}/config/config.default.js\nexports.webpack = {\n  // port: 9000,  \n\n  // webpackConfigList: [],\n};\n```\n\n- **port**: {Number}, default 9000。webpack dev server port, default 9000,  when hava multile webpack config, the port incremented。\n- **offsetPort**: {Boolean}, default false。when mutil webpack target web config, need set true。\n- **browser**: {Boolean | String}  if it is boolean type, whether to open the browser automatically, defualt true; if it is string。\nThat is url address, will automatically open the browser's url address。\n- **proxy**: {Boolean | Object}. webpack compiled in a separate service inside, default webpack service is http://127.0.0.1:9000, you can set koa-proxy options access static resources by [koa-proxy](https://github.com/popomore/koa-proxy)。the default options:\n\n```js\nconfig.webpack = {\n  proxy: {\n    host: 'http://127.0.0.1:9000', // target host that matched path will be proxy to\n    match: /^\\/public\\//, // proxy url path pattern.\n  },\n}\n```\n\n- **webpackConfigList**: {Array}, optional, default []. native webpack config.\n- **webpackConfigFile**: {String}, optional, you must set when you easywebpack config file is not in the project root directory。\n\n\n### webpack native configuration\n\n- if you write one native webpack config `${app_root}/build/webpack.config.js`, you can use like this:\n\n```js\n// {app_root}/config/config.default.js\nexports.webpack = {\n  webpackConfigList: [require('../build/webpack.config.js')]\n};\n```\n\n- if you use easywebpack solution, you can use like this:\n\ndefault read `webpack.config.js` file under the project root directory.\n\n```js\nconst EasyWebpack = require('easywebpack-vue');\n// {app_root}/config/config.default.js\nexports.webpack = {\n  webpackConfigList: EasyWebpack.getWebpackConfig()\n};\n```\n\n- if you use easywebpack solution, the easywebpack config file in `${app_root}/build/webpack.config.js`,  you can use like this:\n\n```js\nconst EasyWebpack = require('easywebpack-vue');\n// {app_root}/config/config.default.js\nexports.webpack = {\n  webpackConfigList: EasyWebpack.getWebpackConfig('build/webpack.config.js')\n};\n```\n\n### easywebpack configuration\n\nThe default read `webpack.config.js` file under the project root directory.\n\n```js\n// {app_root}/config/config.default.js\nexports.webpack = {\n  webpackConfigFile: 'build/webpack.config.js', // easywebpack config file path\n};\n```\n\n\nsee [config/config.default.js](config/config.default.js) for more detail.\n\n## Customize\n\n- mount `app.webpack.fileSystem` to app, you can customize the webpack memory file read logic\n\n```js\n// read webpack browser build mode memory file content\napp.webpack.fileSystem.readWebpackMemoryFile(filePath).then(fileContent =\u003e{\n\n})\n```\n\n- render vue from webpack memory\n\n```js\n'usestrict';\nconst path = require('path');\nconst egg = require('egg');\nconst vueServerRenderer = require('vue-server-renderer');\nmodule.exports = class IndexController extends egg.Controller {\n  async index(ctx) {\n    const { app } = ctx;\n    const filepath = path.join(app.config.view.root[0], 'app.js');\n    // server render mode, the webpack config target:node\n    const strJSBundle = await app.webpack.fileSystem.readWebpackMemoryFile(filepath);\n    ctx.body = await vueServerRenderer.createBundleRenderer(strJSBundle).renderToString({});\n  }\n};\n```\n\nsee [lib/server.js](lib/server.js)  for more detail.\n\n\n- monitor webpack build state\n\n```js\napp.messenger.on(app.webpack.Constant.EVENT_WEBPACK_BUILD_STATE, data =\u003e {\n  if (data.state) {\n    const filepath = path.join(app.baseDir, 'config/manifest.json');\n    const promise = app.webpack.fileSystem.readWebpackMemoryFile(filepath);\n    promise.then(content =\u003e {\n      fs.writeFileSync(filepath, content, 'utf8');\n    });\n  }\n});\n```\n\nsee [lib/constant.js](lib/constant.js) for more detail.\n\n## Questions \u0026 Suggestions\n\nPlease open an issue [here](https://github.com/hubcarl/egg-webpack/issues).\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasy-team%2Fegg-webpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feasy-team%2Fegg-webpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasy-team%2Fegg-webpack/lists"}