[英]Webpack - Output Files are not generating
我正在使用webpack作為捆綁程序和用於創建服務器的nodejs創建一個簡單的react應用程序。 問題是我的webpack沒有在目標文件夾中生成輸出文件。 我沒有看到任何錯誤,並且http://localhost:3000
顯示了我期望的內容,但是未生成dist
文件夾。
這與熱模塊重新發布有關,並且webpack正在為我生成所有內容。 我不確定。 我是新來的反應者,任何幫助將不勝感激。
謝謝
webpack.config.js
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'eval',
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./src/index'
],
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')
}]
}
};
package.json
"scripts": {
"start": "node server.js",
"lint": "eslint src"
},
//remaining dependencies
server.js
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config');
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
historyApiFallback: true
}).listen(3000, 'localhost', function (err, result) {
if (err) {
return console.log(err);
}
console.log('Listening at http://localhost:3000/');
});
您應該使用“ webpack”而不是“ webpack-dev-server”,因為“ webpack”確實會將代碼生成到磁盤,而“ webpack-dev-server”只是將代碼提供給本地主機
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.