A sh loader for webpack. Transform .sh file to an object.
To begin, you'll need to install sh-loader
:
npm install sh-loader --save-dev
Then add the loader to your webpack
config. For example:
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.sh$/,
use: "sh-loader",
},
],
},
};
Now, you can import .sh
file.
import sh from './mongod.sh'
console.log(sh)
// eventually converted to this type of JSON
{
origin: "mongod --dbpath db --logpath log/mongod.log --bg=red", // source
originArr: ["mongod --dbpath db --logpath log/mongod.log --bg=red"], // source array split with '\n'
detail: [{
command: "mongod", // command name
params: {
_: [
"mongod"
],
dbpath: "db",
logpath: "log/mongod.log",
bg: "red"
} // command params
}]
}
And run webpack
via your preferred method.
Name | Type | Default | Description |
---|---|---|---|
parse | {Boolean} |
true |
Enable/Disable parse |