diff --git a/package.json b/package.json index cd56f858..5aedf8a5 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "babel-loader": "^8.0.0-beta.0", "browser-sync": "^2.23.5", "browser-sync-webpack-plugin": "^2.2.2", + "chokidar": "^2.0.3", "clean-webpack-plugin": "^0.1.19", "css-loader": "^0.28.11", "cssnano": "^3.10.0", diff --git a/webpack.config.js b/webpack.config.js index 6bd3ca9f..ed9ad25e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,6 +2,7 @@ const fs = require('fs'); const url = require('url'); const path = require('path'); const glob = require('glob'); +const chokidar = require('chokidar'); const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); const { ProvidePlugin } = require('webpack'); @@ -159,6 +160,16 @@ if (svgs.length) { ); } +chokidar.watch('./assets/styles/').on('add', () => { + const main = './assets/styles/main.css'; + + fs.appendFile(main, '/*CHANGE*/', () => { + fs.readFile(main, 'utf8', (err, data) => { + fs.writeFileSync(main, data.replace(/\n?\/\*CHANGE\*\//gm, '')); + }); + }); +}); + module.exports = env => { const isDevelopment = env.NODE_ENV === 'development'; const isProduction = env.NODE_ENV === 'production'; diff --git a/yarn.lock b/yarn.lock index 0fc023f4..ce56b7f7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2152,7 +2152,7 @@ chokidar@1.7.0: optionalDependencies: fsevents "^1.0.0" -chokidar@^2.0.2: +chokidar@^2.0.2, chokidar@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.0.3.tgz#dcbd4f6cbb2a55b4799ba8a840ac527e5f4b1176" dependencies: