1
0
mirror of https://github.com/locomotivemtl/locomotive-boilerplate.git synced 2026-01-15 00:55:08 +08:00

Add support for task options

Added support for customizing processors in `scripts.js` (esbuild), `styles.js` (node-sass, postcss, autoprefixer), and `svgs.js` (svg-mixer), via arguments for the exported task functions.

Added:
- Constants to decouple shared default options, options for development, and options for production.
- Constants to export default options for development and production as an array of arguments to pass to task functions.

Changed:
- watch.js to apply development args to tasks
This commit is contained in:
Chauncey McAskill
2021-09-21 17:33:32 -04:00
parent 6ded72bc79
commit 9e3d304654
6 changed files with 218 additions and 50 deletions

View File

@@ -1,8 +1,8 @@
import loconfig from '../loconfig.json';
import concatFiles from './tasks/concats.js';
import compileScripts from './tasks/scripts.js';
import compileStyles from './tasks/styles.js' ;
import compileSVGs from './tasks/svgs.js';
import compileScripts, { developmentScriptsArgs } from './tasks/scripts.js';
import compileStyles, { developmentStylesArgs } from './tasks/styles.js' ;
import compileSVGs, { developmentSVGsArgs } from './tasks/svgs.js';
import template from './utils/template.js';
import server from 'browser-sync';
import { join } from 'node:path';
@@ -30,9 +30,9 @@ server.init(serverConfig);
// Build scripts, compile styles, concat files,
// and generate spritesheets on first hit
concatFiles();
compileScripts();
compileStyles();
compileSVGs();
compileScripts(...developmentScriptsArgs);
compileStyles(...developmentStylesArgs);
compileSVGs(...developmentSVGsArgs);
// and call any methods on it.
server.watch(
@@ -50,7 +50,7 @@ server.watch(
join(paths.scripts.src, '**/*.js'),
]
).on('change', () => {
compileScripts();
compileScripts(...developmentScriptsArgs);
});
// Watch concats
@@ -69,7 +69,7 @@ server.watch(
join(paths.styles.src, '**/*.scss'),
]
).on('change', () => {
compileStyles();
compileStyles(...developmentStylesArgs);
});
// Watch svgs
@@ -78,5 +78,5 @@ server.watch(
join(paths.svgs.src, '*.svg'),
]
).on('change', () => {
compileSVGs();
compileSVGs(...developmentSVGsArgs);
});