我在 Ubuntu 15.10 的虚拟机上使用 vagrant 在 mac OSX 上运行 webpack 服务器。
webpack 配置非常干净:
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var webpack = require('webpack');
var MINIFY = process.env.MINIFY === true;
var FRONTEND_ROOT = './static'
var SRC_PATCH = FRONTEND_ROOT + '/scripts';
var BUILD_PATH = './dist';
module.exports = {
entry: SRC_PATCH + '/main.js',
devtool: 'source-map',
output: {
path: BUILD_PATH,
filename: 'bundle.js'
},
resolve: {
extensions: ['', '.js', '.jsx'],
modulesDirectories: [SRC_PATCH, 'node_modules']
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.resolve(FRONTEND_ROOT, 'index-template.html'),
minify: MINIFY
})
],
module: {
loaders: [
{
test: /\.jsx|js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}
]
},
eslint: {
configFile: './.eslintrc'
}
};
Webpack 是在 VM 上运行的
vagrant@vagrant-ubuntu-wily-64:/vagrant$ webpack-dev-server --port 8080 --devtool eval --progress --colors --hot --content-base dist
当我从 OSX 编辑文件时,它不会重新加载,但如果我从 VM 编辑同一个文件,它会重新加载。
有什么问题?我该如何解决?
最佳答案
我已经用 vagrant 解决了我的问题 rsync-auto
https://docs.vagrantup.com/v2/cli/rsync-auto.html
我添加了行 config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync_auto: true, rsync_exclude: ".git/"
到我的 Vagrantfile
,然后运行 vagrant rsync-auto
在单独的选项卡下。
关于vagrant - Webpack 开发服务器重新加载在虚拟机上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33681004/