Snowpack plugin that executes shell commands sequentially when the bundle is generated.
This plugin requires an LTS Node version (v8.0.0+) and Snowpack v2.0.0+.
Using npm:
npm install --save-dev snowpack-plugin-run
Create a snowpack.config.js
configuration file and execute a single shell command when the bundle is generated by setting the value of cmd
to a single string:
const dsv = require('snowpack-plugin-run');
module.exports = {
mount: {
public: { url: '/', static: true },
src: { url: '/dist' },
},
plugins: [
[
'snowpack-plugin-run',
{
cmd: 'start chrome --new-window http://localhost/',
},
],
],
};
Execute multiple shell commands sequential when the bundle is generated by setting the value of cmd
to an array of strings:
const dsv = require('snowpack-plugin-run');
const path = require('path');
module.exports = {
mount: { ... },
plugins: [
[
'snowpack-plugin-run',
{
cmd: [
// Copy index.html from src to public if index.html is not modified
'robocopy src public index.html',
// Then open the browser
'start firefox -new-window "' + path.join(process.cwd(), 'public', 'index.html') + '"'
],
},
],
],
};