npm-submodule-webpack-plugin

0.0.5 • Public • Published

Build Status

NPM Submodule Webpack Plugin

Run npm commands in a module inside the node_modules folder.

Install

$ npm install --save-dev npm-submodule-webpack-plugin

Usage

Let say that you have something similar in your package.json:

  "dependencies": {
    "myproject": "git+https://my.private/repo.git#1234567"
  }

And you would like to run the following npm commands in the node_modules/myproject folder:

$ npm run compile
$ npm run dist

Then you need to add the following lines into your webpack.config.js:

var NpmSubmodulePlugin = require("npm-submodule-webpack-plugin");
  plugins: [
    new NpmSubmodulePlugin({
      module: 'myproject',
      autoInstall: true,
      commands: [
        'compile',
        'dist'
      ]
    })
  ]

The autoInstall field allows the plugin to run npm install if the node_modules folder is not exists. This is a boolean field, and false by default.

By default, the plugins use the console.log method to log the output of the command, but it is possible, to use a custom logger:

  plugins: [
    new NpmSubmodulePlugin({
      module: 'myproject',
      commands: [
        'install',
        'compile'
      ],
      logger: my-logger-method
    })
  ]

Working with arguments:

  plugins: [
    new NpmSubmodulePlugin({
      module: 'myproject',
      commands: [
        'install --save react'
      ]
    })
  ]

Package Sidebar

Install

npm i npm-submodule-webpack-plugin

Weekly Downloads

17

Version

0.0.5

License

MIT

Last publish

Collaborators

  • mikcsabee