0.0.5 • Published 5 years ago

webpack-auto-find-port v0.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

English | 简体中文

Overview

A library for help webpack devserver find usable port when has port conflict.

Install

npm install webpack-auto-find-port -D

API

paramdescriptiontyperequired
configprovider the webpack devserver config.objectyes
loggerreturn the port with callbackfunctionno

Usage

const webpackAutoFindPort = require('webpack-auto-find-port')
// here is your webpack devServer config
// ...code

module.exports = webpackAutoFindPort({
  config: webpackDevConfig,
  logger: (port) => {}
})

Example

You can run Example demo

cd example

npm install

# Now you can sperate two terminal in your local
# Run below command in each terminal

npm run dev

Detail config.

const path = require('path')
const chalk = require('chalk')
const merge = require('webpack-merge')
const webpack = require('webpack')
const webpackBaseConfig = require('./webpack.base.config')
// here, we import our plugin
const webpackAutoFindPort = require('webpack-auto-find-port')

const webpackDevConfig = merge(webpackBaseConfig, {
  mode: 'development',
  devtool: 'inline-source-map',
  devServer: {
    contentBase: path.resolve(`${process.cwd()}`, '../dist/index.html'),
    publicPath: '/',
    compress: true,
    noInfo: true,
    disableHostCheck: true,
    open: true,
    inline: true,
    port: 8080
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin()
  ]
})

// here, export our config
module.exports = webpackAutoFindPort({
  config: webpackDevConfig,
  logger: (port) => {
    console.log('P is Runing at', port)
  }
})

Author

👤 biyuqiwan@163.com

🤝 Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

📝 License

Copyright © 2019 biyuqiwan@163.com. This project is MIT licensed.

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago