我正在使用webpack 4,由于某种原因,我无法将.js文件放入名为/ js /的文件夹中,我的图像文件不会进入图像文件夹。这是我的webpack配置文件。理想情况下,看到图像保留源名称和路径名称会很棒。这是我的配置文件
const HtmlWebPackPlugin = require("html-webpack-plugin");
const path = require('path');
module.exports = {
entry: [
'./src/index.js'
],
output: {
path: path.resolve(__dirname, "public"), // string
publicPath: 'js/',
filename: "desktop.js"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader?presets[]=es2015"
}
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
name: '[path][name].[hash].[ext]',
publicPath: '[path][name]',
bypassOnDebug: true,
},
},
],
},
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
},
{
test: /\.html$/,
use: [
{
loader: "html-loader",
options: { minimize: false }
}
]
}
]
},
plugins: [
new HtmlWebPackPlugin({
template: "./src/index.html",
filename: "./index.html"
})
]
};