Skip to content

Commit 830c29f

Browse files
committed
Rollup cache by default and close bundle after write : global chokidar : config file watching
1 parent 6d03ca2 commit 830c29f

File tree

7 files changed

+39
-37
lines changed

7 files changed

+39
-37
lines changed

bin/rollup.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,7 @@ const options = () => {
5555
*
5656
* @type {Source} https://github.com/paulmillr/chokidar
5757
*/
58-
const watcher = chokidar.watch(options().globs, {
59-
usePolling: false,
60-
awaitWriteFinish: {
61-
stabilityThreshold: 750
62-
}
63-
});
58+
const watcher = chokidar.watch(options().globs, global.chokidar);
6459

6560
/**
6661
* Main script process
@@ -72,7 +67,8 @@ const main = async (script) => {
7267
/** Lint file */
7368
if (!args.nolint) await lint.main(script.input);
7469

75-
if (script.hasOwnProperty('devModule')) delete script.devModule;
70+
if (script.hasOwnProperty('devModule'))
71+
delete script.devModule;
7672

7773
const bundle = await rollup.rollup(script);
7874

@@ -82,6 +78,8 @@ const main = async (script) => {
8278
cnsl.describe(`${alerts.rollup} Rollup in ${alerts.str.path(script.input)} out ` +
8379
`${alerts.str.path(script.output[i].file)}`);
8480
}
81+
82+
bundle.close();
8583
} catch (err) {
8684
cnsl.error(`Rollup failed (main): ${err.stack}`);
8785
}

bin/serve.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,12 @@ const GLOBS = [
3131
`${DIST}/**/*.js`
3232
];
3333

34-
/**
34+
/**
3535
* Our Chokidar Watcher
3636
*
3737
* @type {Source} https://github.com/paulmillr/chokidar
3838
*/
39-
const watcher = chokidar.watch(GLOBS, {
40-
usePolling: false,
41-
awaitWriteFinish: {
42-
stabilityThreshold: 750
43-
}
44-
});
39+
const watcher = chokidar.watch(GLOBS, global.chokidar);
4540

4641
/**
4742
* The Express App

bin/slm.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ const options = () => {
3838
source: source,
3939
dist: path.join(global.base, global.dist),
4040
base_path: base_path,
41-
views: `${base_path}/${global.entry.views}`,
41+
views: path.join(base_path, global.entry.views),
4242
ext: ext,
4343
globs: config.globs || [
4444
resolve('config/slm', false),
45-
`${source}/**/*${ext}`,
46-
`${source}/**/*.md`
45+
path.join(source, `/**/*${ext}`),
46+
path.join(source, '/**/*.md')
4747
]
4848
}
4949
}
@@ -53,12 +53,7 @@ const options = () => {
5353
*
5454
* @type {Source} https://github.com/paulmillr/chokidar
5555
*/
56-
const watcher = chokidar.watch(options().globs, {
57-
usePolling: false,
58-
awaitWriteFinish: {
59-
stabilityThreshold: 750
60-
}
61-
});
56+
const watcher = chokidar.watch(options().globs, global.chokidar);
6257

6358
/**
6459
* Write the html file to the distribution folder

bin/styles.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ const options = () => {
3232
return {
3333
modules: modules,
3434
globs: [
35-
`${path.join(global.base, global.src)}/**/*.scss`,
36-
tokens.options().input,
37-
tokens.options().tailwindcss
35+
resolve('config/tokens', false),
36+
resolve('config/tailwindcss', false),
37+
resolve('config/sass', false),
38+
resolve('config/postcss', false),
39+
path.join(global.base, global.src, '/**/*.scss')
3840
]
3941
}
4042
};
@@ -67,10 +69,7 @@ const main = async (modules) => {
6769
*/
6870
const watcher = chokidar.watch(options().globs, {
6971
ignored: tokens.options().output.replace(/"/g, ''),
70-
usePolling: false,
71-
awaitWriteFinish: {
72-
stabilityThreshold: 750
73-
}
72+
...global.chokidar
7473
});
7574

7675
/**

bin/svgs.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ const options = () => {
3131
m.ext = '.svg';
3232

3333
return m;
34-
})
34+
}),
35+
globs: [
36+
resolve('config/svgs', false)
37+
]
3538
}
3639
};
3740

@@ -191,11 +194,10 @@ const run = async () => {
191194

192195
if (!fs.existsSync(mod.source)) continue;
193196

194-
const globs = [
195-
`${mod.source}/**/*${mod.ext}`
196-
];
197-
198-
const watcher = chokidar.watch(globs, {
197+
const watcher = chokidar.watch([
198+
`${mod.source}/**/*${mod.ext}`,
199+
...opts.globs
200+
], {
199201
usePolling: false,
200202
awaitWriteFinish: {
201203
stabilityThreshold: 750
@@ -219,7 +221,7 @@ const run = async () => {
219221
cnsl.success(`Svgs finished`);
220222
});
221223

222-
cnsl.watching(`Svgs watching ${alerts.str.ext(globs.join(', '))}`);
224+
cnsl.watching(`Svgs watching ${alerts.str.ext(opts.globs.join(', '))}`);
223225
}
224226
} catch (err) {
225227
console.error(`${alerts.error} Svgs (run): ${err}`);

config/global.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ module.exports = {
2929
svg: 'svg'
3030
},
3131

32+
/**
33+
* Global chokidar options
34+
*
35+
* @type {Object}
36+
*/
37+
chokidar: {
38+
usePolling: false,
39+
awaitWriteFinish: {
40+
stabilityThreshold: 750
41+
}
42+
},
43+
3244
/**
3345
* Directories to scaffold. The scaffold command will create the filesystem
3446
* configured here and use files in the ./scaffold directory as the contents

config/rollup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ let plugins = [
3737
module.exports = [
3838
{
3939
input: path.join(global.base, global.src, global.entry.scripts),
40+
cache: true,
4041
output: [{
4142
file: path.join(global.base, global.dist, global.entry.scripts),
4243
name: global.entry.name,

0 commit comments

Comments
 (0)