2017-05-14 10 views
0

HotModuleReplacementを統合しようとしていて、thisの定型句に従っていますが、Webpackの設定では動作しません。webpack 2でHotModuleReplacementを設定する際に問題が発生しました

「問題」は、output.publicPathのエントリにあります。私が言及した例に続いて、その行は "が、ホットアップデートチャンク"をロードする場所を知るために必要ですが、私がwebpack設定に含めるときに、私にこのエラーGET http://localhost:3000/ 404 (Not Found)を与えます。私はそれが含まれていない場合は、WebPACKのに成功し、すべてをコンパイルしますが、HMRは、私は、コンソールを見たとき、私は以下は、この

[WDS] App hot update... 
dev-server.js:45 [HMR] Checking for updates on the server... 
log-apply-result.js:20 [HMR] Updated modules: 
log-apply-result.js:22 [HMR] - ./src/components/App.js 
dev-server.js:27 [HMR] App is up to date. 

を取得していても動作しませんwebpack.config.jsファイルです。

const path = require('path'); 
const webpack = require('webpack'); 
const HtmlWebpackPlugin = require('html-webpack-plugin'); 

module.exports = { 
    entry: [ 
    'react-hot-loader/patch', 
    'webpack-dev-server/client?http://localhost:3000', 
    'webpack/hot/only-dev-server', 
    './src/index.js' 
    ], 
    output: { 
    filename: 'bundle.js', 
    path: path.resolve(__dirname, 'dist'), 
    publicPath: '/static/' 
    }, 
    devtool: 'inline-source-map', 
    module: { 
    rules: [ 
     { test: /\.(js)$/, exclude: /node_modules/, use: ['react-hot-loader/webpack', 'babel-loader'] }, 
     { test: /\.css$/, use: [ 'style-loader', 'css-loader' ] }, 
     { test: /\.(png|jpg)$/, loader: 'file-loader?name=images/[name].[hash].[ext]' }, 
      { test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?name=fonts/[name].[hash].[ext]&mimetype=application/font-woff'}, 
      { test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,loader: 'file-loader?name=fonts/[name].[hash].[ext]&mimetype=application/font-woff'}, 
      { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?name=fonts/[name].[hash].[ext]&mimetype=application/octet-stream'}, 
      { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?name=fonts/[name].[hash].[ext]'}, 
      { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?name=images/[name].[hash].[ext]&mimetype=image/svg+xml' } 
    ] 
    }, 
    plugins: [ 
    new webpack.HotModuleReplacementPlugin(), 
    new webpack.NamedModulesPlugin(), 
    new webpack.NoEmitOnErrorsPlugin(), 
    new HtmlWebpackPlugin({ template: 'public/index.html', favicon: 'public/favicon.ico' }) 
    ], 
    devServer: { 
    host: 'localhost', 
    port: 3000, 
    historyApiFallback: true, 
    hot: true 
    } 
} 

何が欠けていますか?

これらは、念のために、私はそれが働いてしまった

"dependencies": { 
    "react": "^15.5.4", 
    "react-dom": "^15.5.4", 
    "react-prop-types": "^0.4.0", 
    "semantic-ui-css": "^2.2.10", 
    "semantic-ui-react": "^0.68.3" 
    }, 
    "devDependencies": { 
    "babel-core": "^6.24.1", 
    "babel-loader": "^7.0.0", 
    "babel-preset-env": "^1.4.0", 
    "babel-preset-react": "^6.24.1", 
    "babel-preset-stage-1": "^6.24.1", 
    "css-loader": "^0.28.1", 
    "file-loader": "^0.11.1", 
    "html-webpack-plugin": "^2.28.0", 
    "react-hot-loader": "next", 
    "style-loader": "^0.17.0", 
    "webpack": "^2.5.1", 
    "webpack-dev-server": "^2.4.5" 
    } 

EDIT

私のプロジェクトの依存関係です。私は私が新しい質問、{"modules": false}はどういう意味を持っていると思い、私はpublicPath: '/'publicPathを変更し、以下の私の.babelrcファイルに{"modules": false}を追加

は私.babelrcファイル

{ 
    "presets": [["env",{"modules": false}], "react", "stage-1"] 
} 

のですか?それは何のために使われていますか?

答えて

関連する問題