vue can not automatically open the browser

Original link: point I

If it can not automatically open the browser, because there is no plug-in installed.

The method of mounting the plug
1. Plug input in cmd:

NPM-Open Browser I $-WebPACK plugin --save-
I herein represent install, it is an abbreviation.

2. Modify the build \ webpack.dev.conf.js file.
At the top of the bottom statement added:

var OpenBrowserPlugin = require ( 'open- browser-webpack-plugin')
added in the plugins:

new OpenBrowserPlugin({ url: 'http://localhost:8080' }),

var config = require('../config')
var webpack = require('webpack')
var merge = require('webpack-merge')
var utils = require('./utils')
var baseWebpackConfig = require('./webpack.base.conf')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var FriendlyErrors = require('friendly-errors-webpack-plugin')
var OpenBrowserPlugin = require('open-browser-webpack-plugin')

// add hot-reload related code to entry chunks
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
  baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
})

module.exports = merge(baseWebpackConfig, {
  module: {
    loaders: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
  },
  // eval-source-map is faster for development
  devtool: '#eval-source-map',
  plugins: [
    new OpenBrowserPlugin({ url: 'http://192.168.10.105:8080' }),
    new webpack.DefinePlugin({
      'process.env': config.dev.env
    }),
    // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
    new webpack.optimize.OccurrenceOrderPlugin(),
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin(),
    // https://github.com/ampedandwired/html-webpack-plugin
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: 'index.html',
      inject: true
    }),
    new FriendlyErrors()
  ]
})


3. Finally, you can run npm run dev.

Guess you like

Origin www.cnblogs.com/myfate/p/11574097.html