Webpack热重装不能与vhost

时间:2017-01-06 09:02:55

标签: javascript symfony webpack webpack-dev-server

我遇到了WDS的问题。我正在使用Symfony2。

我有我的webpack-dev:" localhost:8080" 我的网站:" mysite.dev"

这是我的webpack.config.js

const PATHS = {
    app: path.join(__dirname, 'js'),
    style: path.join(__dirname, 'scss', 'style.scss'),
    build: path.join(__dirname, 'build')
};
entry: {
    hmr: [
        'webpack-dev-server/client?http://localhost:8080',
        'webpack/hot/only-dev-server'
    ],
    app: PATHS.app + '/main.js',
    style: PATHS.style
},
output: {
    path: PATHS.build,
    publicPath: '/',
    hotUpdateChunkFilename: 'hot/hot-update.js',
    hotUpdateMainFilename: 'hot/hot-update.json',
    filename: '[name].js',
    sourceMapFilename: '[file].map',
    devtoolModuleFilenameTemplate: 'webpack:///[resource-path]?[loaders]'
},
...
parts.devServer({
    host: process.env.HOST,
    port: process.env.PORT
})

我的web-dev-server config:

 exports.devServer = function(options) {
    return {
        watchOptions: {
             aggregateTimeout: 300,
             poll: 1000
        },
        devServer: {
            publicPath: '/',
            historyApiFallback: true,
            hot: true,
            stats: 'errors-only',
            host: options.host, // Defaults to `localhost`
            port: options.port // Defaults to 8080
        },
        plugins: [
            new webpack.HotModuleReplacementPlugin(),
            new webpack.WatchIgnorePlugin([
                path.join(__dirname, 'node_modules')
            ])
        ]
     };
 };

在我的index.twig中,我有:

{% block main_javascripts %}
     <script type="text/javascript" src="http://localhost:8080/app.js"></script>
     <script type="text/javascript" src="http://localhost:8080/style.js"></script>
     <script type="text/javascript" src="http://localhost:8080/hmr.js"></script>
 {% endblock %}

当我使用localhost:8080时,Hot reload有效。 但是在我的mysite.dev中我有这个问题:

 GET http://mysite.dev/hot/hot-update.json 404 (Not Found)
 [HMR] Cannot find update. Need to do a full reload!
 [HMR] (Probably because of restarting the webpack-dev-server)

有什么想法吗?

谢谢,

0 个答案:

没有答案