Skip to content

Commit

Permalink
fix: fix build:watch using chokidar
Browse files Browse the repository at this point in the history
  • Loading branch information
dylandepass committed Dec 13, 2023
1 parent aa22acf commit d215fa8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
29 changes: 29 additions & 0 deletions build/watch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2023 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

/* eslint-disable no-console */
// eslint-disable-next-line import/no-extraneous-dependencies
import chokidar from 'chokidar';
import { exec } from 'child_process';

chokidar.watch(['src/'])
.on('change', () => {
exec('npm run build', (error, stdout, stderr) => {
if (error) {
console.error(`${error.name}: ${error.message}`);
console.error(`[STACK] ${error.stack}`);
}

console.log(stdout);
console.log(stderr);
});
});
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test": "npm run test:mocha && npm run test:wtr",
"docs": "npx jsdoc2md -c .jsdoc.json --files './src/*.js' > docs/API.md",
"semantic-release": "semantic-release",
"build:watch": "rimraf dist && rollup -c rollup.config.js --watch && npm run build:analyze",
"build:watch": "rimraf dist && npm run build && node build/watch.js",
"build": "rimraf dist && rollup -c rollup.config.js && npm run build:analyze",
"build:analyze": "npm run analyze -- --globs src/extension/app/aem-sidekick.js",
"build:safari": "node ./build/build-browser.js safari",
Expand Down Expand Up @@ -71,6 +71,7 @@
"archiver": "6.0.1",
"c8": "8.0.1",
"codecov": "3.8.3",
"chokidar": "3.5.3",
"eslint": "8.55.0",
"fs-extra": "11.2.0",
"husky": "8.0.3",
Expand Down
4 changes: 0 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ function plugins(browser) {

function extensionBuild(browser) {
return {
watch: {
include: './src/**',
clearScreen: true,
},
...shared(browser),
plugins: [...plugins(browser)],
};
Expand Down

0 comments on commit d215fa8

Please sign in to comment.