Skip to content

mikcsabee/npm-submodule-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'
      ]
    })
  ]

About

Webpack plugin to handle submodule npm commands

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published