0
我得到一個空白的html文檔。但是,當我查看src代碼時,我看到我的腳本標記引用dist/app.js,這是我的捆綁代碼。webpack輸出不顯示在index.html中
這是我的WebPack這裏是我的index.html
而且,這裏是我的文件夾結構。
/dist/app.js
/node_modules
/src/index.js
index.html
package.json
webpack.config.js
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
homepage: './src/index.js',
},
output: {
filename: './dist/app.js'
},
// Resolve the `./src` directory so we can avoid writing
// ../../styles/base.css
resolve: {
extensions: ['.js', '.jsx']
},
// Instruct webpack how to handle each file type that it might encounter
module: {
loaders:[
{
test: /\.js[x]?$/, exclude: /node_modules/, loader: 'babel-loader',
query: {
///plugins: ['transform-runtime'],
presets: ["es2015", "react"]
}
}
]
},
// This plugin moves all the CSS into a separate stylesheet
plugins: [
new ExtractTextPlugin('app.css')
]
};
<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
</head>
<body>
<script src="/dist/app.js"></script>
</body>
</html>
你如何查看index.html文件?直接從硬盤或通過開發服務器提供? – ideaboxer
通過開發服務器。我正在運行npm start。 – user8280738
瀏覽器控制檯沒有錯誤? – ideaboxer