https://github.com/funbox/rebuild-in-progress-webpack-plugin
Creates the file indicator at the beginning of the build and deletes it at the end
https://github.com/funbox/rebuild-in-progress-webpack-plugin
webpack webpack-plugin
Last synced: 11 months ago
JSON representation
Creates the file indicator at the beginning of the build and deletes it at the end
- Host: GitHub
- URL: https://github.com/funbox/rebuild-in-progress-webpack-plugin
- Owner: funbox
- License: mit
- Created: 2020-07-20T11:41:12.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-07-19T02:51:43.000Z (almost 3 years ago)
- Last Synced: 2025-07-11T20:41:37.956Z (12 months ago)
- Topics: webpack, webpack-plugin
- Language: JavaScript
- Homepage:
- Size: 261 KB
- Stars: 5
- Watchers: 10
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @funboxteam/rebuild-in-progress-webpack-plugin
[](https://www.npmjs.com/package/@funboxteam/rebuild-in-progress-webpack-plugin)
Webpack plugin that creates the file indicator at the beginning of the build and deletes it at the end.
[По-русски](./README.ru.md)
## Rationale
Sometimes external programs have to know the project building state. E.g. it's important to have this knowledge for
tests running (especially E2E), because testing should be started when the project is completely built.
To solve this problem **RebuildInProgress** plugin was created. It creates the file `node_modules/.rebuildInProgress`
when webpack starts to build the project and removes it at the end.
## Usage
Add the plugin in `plugins` array as usual:
```javascript
const RebuildInProgressPlugin = require('@funboxteam/rebuild-in-progress-webpack-plugin');
module.exports = {
plugins: [
new RebuildInProgressPlugin()
]
}
```
Set the path to the file if the default one isn't suitable:
```javascript
const RebuildInProgressPlugin = require('@funboxteam/rebuild-in-progress-webpack-plugin');
const rebuildInProgressPath = 'node_modules/.alternativeName';
module.exports = {
plugins: [
new RebuildInProgressPlugin(rebuildInProgressPath)
]
}
```
## Build state watching
Here's an example of watching for build state using
[`fs`]((https://nodejs.org/docs/latest/api/fs.html#fs_fs_watch_filename_options_listener)):
```javascript
const fs = require('fs');
const rebuildInProgressPath = 'node_modules/.rebuildInProgress';
fs.watch(path.dirname(rebuildInProgressPath), (eventType, filename) => {
if (eventType === 'rename' && filename === path.basename(rebuildInProgressPath)) {
if (fs.existsSync(rebuildInProgressPath)) {
// Build has been started
} else {
// Build has been completed
}
}
});
```
[](https://funbox.ru)