Skip to content

Commit

Permalink
Make new stylesheets trigger postcss compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptex committed Apr 18, 2018
1 parent 908bd3d commit 4c29e8b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4c29e8b

Please sign in to comment.