• vue无法自动打开浏览器


    原文链接: 点

    如果不能自动打开浏览器,是因为没有安装插件。

    插件安装的方法
    1.安装插件,在cmd中输入:

    $ npm i open-browser-webpack-plugin --save
    这里的 i 表示 install ,是缩写。

    2.修改buildwebpack.dev.conf.js文件。
    在顶部声明最下面加入:

    var OpenBrowserPlugin = require('open-browser-webpack-plugin')
    在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.最后,在运行npm run dev 即可。

  • 相关阅读:
    洛谷 P2695 骑士的工作
    洛谷 P2839 畅通工程
    hdu_5742_It's All In The Mind
    hdu_5734_Acperience
    hdu_5738_Eureka(脑洞)
    hdu_5724_Chess(组合博弈)
    Codeforces Round #363 (Div. 2)D. Fix a Tree(并查集)
    Codeforces Round #363 (Div. 2) B. One Bomb (水题)
    Codeforces Round #363 (Div. 2) C. Vacations(DP)
    hdu_5723_Abandoned country(最小生成树)
  • 原文地址:https://www.cnblogs.com/myfate/p/11574097.html
Copyright © 2020-2023  润新知