npm chokidar로 style 코드 찾는방법

npm chokidar로 style 코드 찾는방법

QA

npm chokidar로 style 코드 찾는방법

본문

npm install chokidar로 설치는 했는데 

 

파일수정시 style코드를 찾는 방법을 어떻게 활용해야하나요?

 

자바스크립트로 불러와도 에러가 나는데

이 질문에 댓글 쓰기 :

답변 2

아래의 코드를 한번 참고해 보시겠어요..

 

const chokidar = require('chokidar');
const fs = require('fs');

// 감시할 파일 경로
const filePath = 'path/to/your/file.css';

// 파일 감시
const watcher = chokidar.watch(filePath, {
  persistent: true
});

// 파일 변경 이벤트 처리
watcher.on('change', path => {
  console.log(`File ${path} has been changed`);
  
  // 변경된 파일 내용 읽기
  fs.readFile(filePath, 'utf8', (err, data) => {
    if (err) {
      console.error(err);
      return;
    }
    
    // 변경된 파일 내용 출력 (또는 다른 처리)
    console.log('Updated file content:');
    console.log(data);
  });
});

// 감시 시작 메시지 출력
console.log(`Watching for file changes on ${filePath}`);
 

 

 

답변을 작성하시기 전에 로그인 해주세요.
전체 9
QA 내용 검색
filter #npm ×

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT