gpt4 book ai didi

webpack - 选择打开哪个Webpack浏览器?

转载 作者:行者123 更新时间:2023-12-01 00:25:54 26 4
gpt4 key购买 nike

我使用找到的here使用CLI安装了Vue.js:

# install vue-cli
$ npm install --global vue-cli
# create a new project using the "webpack" template
$ vue init webpack my-project
# install dependencies and go!
$ cd my-project
$ npm install
$ npm run dev

当我运行它时,将打开我的默认浏览器Safari。我想指定Chrome(仅用于开发)而不更改操作系统的默认浏览器。

webpack.dev.conf.js如下所示:
var utils = require('./utils')
var webpack = require('webpack')
var config = require('../config')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var FriendlyErrorsPlugin = require('friendly-errors-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: {
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
},
// cheap-module-eval-source-map is faster for development
devtool: '#source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': config.dev.env
}),
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
new FriendlyErrorsPlugin()
]
})

有人知道如何在此配置中指定Chrome吗?

最佳答案

在github上已经为它分配了一个问题,但它仍在开发中。

Issue Link

更新

问题终于合并了。现在,您可以使用CLI或webpack.dev.conf指定浏览器。

  • 使用CLI "start": "webpack-dev-server --config webpack.dev.js --open chrome"
  • 使用webpack.config.js:
    module.exports = {
    //...
    devServer: {
    open: 'Google Chrome'
    }
    };

    Documentation Link
  • 关于webpack - 选择打开哪个Webpack浏览器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44921308/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com