2016-07-03 79 views
1

因此,webpack並沒有更新我所做的任何更改或重新編譯build.js的更改。令人沮喪的問題。不確定交易是什麼。真的可以使用一些幫助!謝謝!代碼如下。Webpack開發服務器沒有觀看或更新文件

webpack.config.js

var webpack = require("webpack"); 
var path = require("path"); 

var DEV = path.resolve(__dirname, "dev"); 
var OUTPUT = path.resolve(__dirname, "output"); 

var config = { 
    watch: true, 
    devtool: 'inline-source-map', 
    entry: [ 
    'webpack-dev-server/client?http://localhost:8080/', 
    'webpack/hot/only-dev-server', 
    DEV + "/App.jsx" 
    ], 
    output: { 
    path: OUTPUT, 
    filename: "build.js" 
    }, 
    module: { 
    loaders: [{ 
     include: DEV, 
     loaders: ["react-hot", "babel"], 
    }] 
    }, 
    plugins: [ 
    new webpack.HotModuleReplacementPlugin(), 
    new webpack.NoErrorsPlugin() 
    ] 
}; 

module.exports = config; 

的package.json

{ 
    "name": "app", 
    "version": "1.0.0", 
    "description": "", 
    "main": "index.js", 
    "scripts": { 
    "start": "webpack-dev-server" 
    }, 
    "author": "", 
    "license": "ISC", 
    "dependencies": { 
    "babel-core": "^6.10.4", 
    "babel-loader": "^6.2.4", 
    "babel-preset-es2015": "^6.9.0", 
    "babel-preset-react": "^6.11.1", 
    "react": "^15.2.0", 
    "react-dom": "^15.2.0", 
    "react-hot-loader": "^1.3.0", 
    "webpack": "^1.13.1", 
    "webpack-dev-server": "^1.14.1" 
    }, 
    "babel": { 
    "presets": [ 
     "es2015", 
     "react" 
    ] 
    } 
} 

我跑./node_modules/.bin/webpack得到初步建立。

讓我知道你是否需要更多信息。再次感謝。

+0

你嘗試傳遞'-w'的命令如'的WebPack -w ' – KhaledMohamedP

+0

'./node_modules/.bin/webpack -w' – KhaledMohamedP

+0

我試過了,它會更新,但現在每次保存文件時,hot-update.js和hot-update.json都會放到我的輸出文件夾中。 – maxwellgover

回答

0

React-Hot-Loader在其配置中可以非常具體。我會嘗試minimal successful configuration的陣營熱裝載機(注意通過變量的初始化採用類似的路徑和不path.resolve):

var path = require('path'); 
var webpack = require('webpack'); 

module.exports = { 
    devtool: 'eval', 
    entry: [ 
    'webpack-dev-server/client?http://localhost:8080', 
    'webpack/hot/only-dev-server', 
    './src/App.jsx' 
    ], 
    output: { 
    path: path.join(__dirname, 'dist'), 
    filename: 'bundle.js', 
    publicPath: '/static/' 
    }, 
    plugins: [ 
    new webpack.HotModuleReplacementPlugin() 
    ], 
    module: { 
    loaders: [{ 
     test: /\.js$/, 
     loaders: ['react-hot', 'babel'], 
     include: path.join(__dirname, 'src') 
    }] 
    } 
}; 
相關問題