2020-11-27 16:01:54 -05:00
|
|
|
import { buildScripts } from './scripts.js';
|
|
|
|
|
import { concatVendors } from './concat.js';
|
|
|
|
|
import { compileStyles } from './styles.js' ;
|
|
|
|
|
import { generateSpriteSVG } from './svgs.js';
|
2018-09-05 14:21:37 -04:00
|
|
|
import paths from '../mconfig.json';
|
2020-11-27 16:01:54 -05:00
|
|
|
|
|
|
|
|
// Create an named instance in one file...
|
2021-09-16 13:55:29 -04:00
|
|
|
import server from 'browser-sync';
|
2020-11-27 16:01:54 -05:00
|
|
|
|
|
|
|
|
// Start the Browsersync server
|
2021-09-16 13:55:29 -04:00
|
|
|
let serverConfig = {
|
2020-11-27 16:01:54 -05:00
|
|
|
open: false,
|
|
|
|
|
notify: false
|
2021-06-28 21:33:10 -04:00
|
|
|
};
|
|
|
|
|
|
2021-09-16 13:54:49 -04:00
|
|
|
if (typeof paths.url === 'string' && paths.url.length > 0) {
|
2021-06-28 21:33:10 -04:00
|
|
|
// Use proxy
|
2021-09-16 13:55:29 -04:00
|
|
|
serverConfig.proxy = paths.url;
|
2021-06-28 21:33:10 -04:00
|
|
|
} else {
|
|
|
|
|
// Use base directory
|
2021-09-16 13:55:29 -04:00
|
|
|
serverConfig.server = {
|
|
|
|
|
baseDir: paths.dest
|
|
|
|
|
};
|
2021-06-28 21:33:10 -04:00
|
|
|
}
|
|
|
|
|
|
2021-09-16 13:55:29 -04:00
|
|
|
server.init(serverConfig);
|
2020-11-27 16:01:54 -05:00
|
|
|
|
2020-11-27 16:15:36 -05:00
|
|
|
// Build scripts, compile styles, concat vendors and generate the svgs sprite on first hit
|
|
|
|
|
buildScripts();
|
|
|
|
|
concatVendors();
|
|
|
|
|
compileStyles();
|
|
|
|
|
generateSpriteSVG();
|
|
|
|
|
|
2020-11-27 16:01:54 -05:00
|
|
|
// and call any methods on it.
|
2021-09-16 13:55:29 -04:00
|
|
|
server.watch(
|
2020-11-27 16:01:54 -05:00
|
|
|
[
|
|
|
|
|
paths.views.src,
|
|
|
|
|
paths.scripts.dest + paths.scripts.main + '.js',
|
|
|
|
|
paths.scripts.dest + paths.scripts.vendors.main + '.js',
|
|
|
|
|
paths.styles.dest + paths.styles.main + '.css',
|
|
|
|
|
paths.svgs.dest + 'sprite.svg'
|
|
|
|
|
]
|
2021-09-16 13:55:29 -04:00
|
|
|
).on('change', server.reload);
|
2020-11-27 16:01:54 -05:00
|
|
|
|
2021-06-28 21:33:10 -04:00
|
|
|
// Watch scripts
|
2021-09-16 13:55:29 -04:00
|
|
|
server.watch(
|
2020-11-27 16:01:54 -05:00
|
|
|
[
|
|
|
|
|
paths.scripts.src + '**/*.js'
|
|
|
|
|
]
|
|
|
|
|
).on('change', () => {
|
|
|
|
|
buildScripts();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Watch scripts vendors
|
2021-09-16 13:55:29 -04:00
|
|
|
server.watch(
|
2020-11-27 16:01:54 -05:00
|
|
|
[
|
|
|
|
|
paths.scripts.vendors.src + '*.js'
|
|
|
|
|
]
|
|
|
|
|
).on('change', () => {
|
|
|
|
|
concatVendors();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Watch styles
|
2021-09-16 13:55:29 -04:00
|
|
|
server.watch(
|
2020-11-27 16:01:54 -05:00
|
|
|
[
|
|
|
|
|
paths.styles.src + '**/*.scss'
|
|
|
|
|
]
|
|
|
|
|
).on('change', () => {
|
|
|
|
|
compileStyles();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Watch svgs
|
2021-09-16 13:55:29 -04:00
|
|
|
server.watch(
|
2020-11-27 16:01:54 -05:00
|
|
|
[
|
|
|
|
|
paths.svgs.src + '*.svg'
|
|
|
|
|
]
|
|
|
|
|
).on('change', () => {
|
|
|
|
|
generateSpriteSVG();
|
|
|
|
|
});
|