4
我第一次使用Webpack。目前一切都很好地服務。我的問題是當我試圖建立一個dist
文件夾。目前我得到我的index.html
和bundle.js
文件,但我無法弄清楚如何將我的資產推送到dist
文件夾。將資產文件夾推送到帶有webpack的公共目錄
我已經加載了文件加載器,但它實際上並沒有做我想做的事情,也沒有我運行的谷歌搜索告訴我我需要知道什麼。以下是我的配置文件。有人能帶馬去水嗎?另外,一旦我運行它,我是否需要將所有圖像導入到我的React組件?
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './app/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/'
},
module: {
rules: [
{ test: /\.(js)$/, use: 'babel-loader' },
{ test: /\.scss$/, use: [ 'style-loader', 'css-loader', 'sass-loader' ]},
{ test: /\.(png|jpe?g|svg|)$/, use: { loader: 'file-loader', options: }}
]
},
devServer: {
historyApiFallback: true,
},
plugins: [
new HtmlWebpackPlugin({
template: 'app/index.html'
})
]
};
嘗試'PublicPath:在module.exports HTTPS/dist':// stackoverflow.com/questions/39277673/webpack-dist-folder-not-getting-created-in-project-folder – yoursweater