Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
- create folder for internal loaders and plugins
- fix the length of the lines
- update readme files
  • Loading branch information
alsolovyev committed Apr 21, 2021
1 parent 6e656f5 commit a4978da
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ Indicates whether TypeScript support should be enabled. <br/>
- [StyleLint](https://github.com/stylelint/stylelint)

- Terminal
- [TerminalClearPlugin](./config/plugins/clearTerminal.plugin.js)
- [TerminalClearPlugin(internal)](./config/modules/terminal-clear-plugin/index.js)

<br/>

Expand Down
30 changes: 30 additions & 0 deletions config/modules/terminal-clear-plugin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Class representing a webpack plugin for clearing the terminal screen.
*
* @requires webpack version >=4
* @version 1.0.0
* @author janeRivas <[email protected]>
* @license MIT
*/
class TerminalClearPlugin {
/**
* @param {Boolean} [saveHistory=true] - indicates whether to keep the terminal history or not
*/
constructor({ saveHistory = true } = { }) {
this.saveHistory = saveHistory
}

/**
* Installs the plugin.
* https://webpack.js.org/contribute/writing-a-plugin/#basic-plugin-architecture
*/
apply(compiler) {
compiler.hooks.beforeCompile.tapAsync('TerminalClearPlugin', (params, callback) => {
process.stdout.write(this.saveHistory ? '\x1B[H\x1B[2J' : '\x1B[2J\x1B[3J\x1B[H\x1Bc')
callback()
})
}
}


module.exports = TerminalClearPlugin
2 changes: 1 addition & 1 deletion config/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
- [StyleLint](https://github.com/stylelint/stylelint)

## Terminal
- [TerminalClearPlugin](./clearTerminal.plugin.js)
- [TerminalClearPlugin(internal)](../modules/terminal-clear-plugin/index.js)
34 changes: 6 additions & 28 deletions config/plugins/clearTerminal.plugin.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
/**
* Class representing a webpack plugin for clearing the terminal screen.
*
* @requires webpack version >=4
* @version 1.0.0
* @author janeRivas <[email protected]>
* @license MIT
*/
class TerminalClearPlugin {
/**
* @param {Boolean} [saveHistory=true] - indicates whether to keep the terminal history or not
*/
constructor({ saveHistory = true } = { }) {
this.saveHistory = saveHistory
}

/**
* Installs the plugin.
* https://webpack.js.org/contribute/writing-a-plugin/#basic-plugin-architecture
*/
apply(compiler) {
compiler.hooks.beforeCompile.tapAsync('TerminalClearPlugin', (params, callback) => {
process.stdout.write(this.saveHistory ? '\x1B[H\x1B[2J' : '\x1B[2J\x1B[3J\x1B[H\x1Bc')
callback()
})
}
}
const TerminalClearPlugin = require('../modules/terminal-clear-plugin')


module.exports = new TerminalClearPlugin()
/**
* Clears the terminal screen.
* ../modules/clear-termina-plugin
*/
module.exports = new TerminalClearPlugin({ })
5 changes: 3 additions & 2 deletions config/webpack/webpack.development.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ module.exports = {
hot: true,
compress: true,
historyApiFallback: true,
before: (app, server) => chokidar.watch('./src/**/*.njk').on('change', () =>
server.sockWrite(server.sockets, 'content-changed')),
before: (app, server) => chokidar.watch('./src/**/*.njk').on('change', () => {
server.sockWrite(server.sockets, 'content-changed')
}),
watchOptions: {
ignored: ['node_modules/**']
}
Expand Down

0 comments on commit a4978da

Please sign in to comment.