From d1866153a8a1fe067ab50a28af13a0111b540433 Mon Sep 17 00:00:00 2001 From: Rube <353371737@qq.com> Date: Wed, 20 Jun 2018 16:18:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20watch=20=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E9=85=8D=E7=BD=AE=20fix=20filecount=20?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/index.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 749562e..399f103 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup-plugin-less", - "version": "0.1.0", + "version": "0.2.0", "description": "a rollup plugin for less files", "main": "dist/rollup-plugin-less.js", "jsnext:main": "dist/rollup-plugin-less.mjs", diff --git a/src/index.js b/src/index.js index 11d5672..383504c 100644 --- a/src/index.js +++ b/src/index.js @@ -18,11 +18,17 @@ let fileCount = 0; export default function plugin (options = {}) { options.insert = options.insert || false; + options.watch = options.watch || false; const filter = createFilter(options.include || [ '**/*.less', '**/*.css' ], options.exclude || 'node_modules/**'); const injectFnName = '__$styleInject' return { name: 'less', + load() { + if (options.watch){ + fileCount = 0; + } + }, intro() { return options.insert ? insertStyle.toString().replace(/insertStyle/, injectFnName) : ''; },