我使用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吗?
发布于 2017-07-05 16:26:05
发布于 2022-03-02 15:26:13
DevServer v4.0.0+
webpack.config.json
{
// ...
devServer:
{
open:
{
app:
{
name: 'firefox'
}
}
},
// ...
}CLI
npx webpack serve --open-app-name 'firefox'
发布于 2022-04-03 15:52:18
对于vue-cli 5.04,目前看来唯一可行的版本是vue.config.js。
module.exports = defineConfig({
devServer: {
open: {
app: {
name: 'opera',
}
}
},
});然而,
vue-cli-service serve --open-app-name 'opera' 不管用。
https://stackoverflow.com/questions/44921308
复制相似问题