qinhua / sh-loader

A sh loader for webpack.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sh-loader

A sh loader for webpack. Transform .sh file to an object.

npm npm coverage size

Getting Started

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.

Options

Name Type Default Description
parse {Boolean} true Enable/Disable parse

License

MIT

About

A sh loader for webpack.

License:MIT License


Languages

Language:JavaScript 100.0%