vagrant - Webpack 开发服务器重新加载在虚拟机上不起作用

标签 vagrant webpack webpack-dev-server

我在 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/

相关文章:

node.js - 无法连接到 Vagrant 中的 Node.js

vue.js - “Cannot read property '在启动vue应用程序时升级' of undefined”

mysql - MySQL安装期间自定义数据目录

vagrant - VBoxManage.exe : error: VMDK: could not create new file : box-disk001. vmdk' (VERR_ALREADY_EXISTS)

node.js - 如何让 "require"继续用于动态表达式

javascript - 分别设置输出文件夹和文件url;使用 Django 的 Webpack 文件加载器

javascript - Webpack 在 JS 文件中抛出一个奇怪的语法错误

javascript - 远程连接到 webpack-dev-server 时收到 "Invalid Host header"消息

node.js - 如何将我的 View 引擎(ejs)添加到 Express 和 Web Pack 开发服务器的组合中?

默认情况下,在 SublimeText 中打开的 Vagrantfile 作为 Ruby 扩展文件