Skip to content

Commit

Permalink
feat: added FilesChanged plugin
Browse files Browse the repository at this point in the history
This plugin shows the files which triggered the change
  • Loading branch information
Florian Weber committed Apr 25, 2019
1 parent 9779759 commit 8b8dc98
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/renderer/plugins/FilesChanged.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import path from 'path';
import chalk from 'chalk';
import logSymbols from 'log-symbols';

export default class FilesChanged {
apply(compiler) {
compiler.hooks.watchRun.tap('averjs', compiler => {
const { watchFileSystem } = compiler;
const watcher = watchFileSystem.watcher || watchFileSystem.wfs.watcher;

let changedFiles = '';
for (const file of Object.keys(watcher.mtimes)) {
changedFiles += ` ${chalk.bold.blue(path.basename(file))},`;
}

console.log(
logSymbols.info,
`Files changed:${changedFiles.slice(0, -1)}`
);
});
}
}
7 changes: 7 additions & 0 deletions packages/renderer/src/base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ExtractCssPlugin from 'extract-css-chunks-webpack-plugin';
import PurgeCssPlugin from 'purgecss-webpack-plugin';
import StyleLoader from './styleLoader';
import Webpackbar from 'webpackbar';
import FilesChanged from '../plugins/FilesChanged';
import { getAverjsConfig } from '@averjs/config';

export default class WebpackBaseConfiguration {
Expand Down Expand Up @@ -41,6 +42,12 @@ export default class WebpackBaseConfiguration {
this.chainConfig
.plugin('vue-loader')
.use(VueLoaderPlugin);

if (!this.isServer && !this.isProd) {
this.chainConfig
.plugin('files-changed')
.use(FilesChanged);
}

this.chainConfig
.plugin('webpackbar')
Expand Down

0 comments on commit 8b8dc98

Please sign in to comment.