我希望你能幫助我。
當我運行webpack時,我的應用程序被構建到dist文件夾中。
不幸的是,img文件夾不會被複制,所以我最終得到一個沒有圖像的應用程序。通過webpack實現這一點的正確方法是什麼,或者哪裏是開始的好地方?我看了一下webpack文檔,但不確定在哪裏看。如何將我的圖像文件夾結構包含在我的React應用程序中?
webpack.config.js文件下
const HtmlWebpackPlugin = require('html-webpack-plugin');
const sass = require('node-sass');
const path = require('path');
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: './index.html',
filename: 'index.html',
inject: 'body'
})
module.exports = {
entry: './index.js',
output: {
path: path.resolve(__dirname, "dist"),
filename: 'bundle.js'
},
module: {
rules: [
{
test:/\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets:['env','react']
}
}
},
{
test: /\.scss$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "sass-loader"
}]
}
],
loaders: [
{ test: /\.json$/, loader: 'json' }
// other loaders
]
},
plugins: [HtmlWebpackPluginConfig]
}
任何幫助深表感謝。
謝謝
萌
謝謝你的輸入。您提供的語法是否缺少關閉']'和'}'或者它是否正確? –
,加上適當的結束標籤。 –
@ Moe-Joe哦,是的,確實是錯字。感謝您指出。我更新了答案。 – WitVault