Image html加载程序设置了错误的路径或忽略index.html中的图像
我的网页有问题,当我在html加载器中设置Image html加载程序设置了错误的路径或忽略index.html中的图像,image,webpack,path,loader,Image,Webpack,Path,Loader,我的网页有问题,当我在html加载器中设置attrs:[':data src']时,我在index.html中有如下良好路径:,但当我使用npm run build时,我在dist文件夹中没有来自此索引的图像。当我有默认的attrs=img:src时,我有图像,但我的路径看起来像:。我试过使用attrs:['data:src','img:src'],但不起作用 我的配置: var webpack = require('webpack'); var path = require('path');
attrs:[':data src']
时,我在index.html中有如下良好路径:
,但当我使用npm run build
时,我在dist文件夹中没有来自此索引的图像。当我有默认的attrs=img:src
时,我有图像,但我的路径看起来像:
。我试过使用attrs:['data:src','img:src'],但不起作用
我的配置:
var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
context: path.join(__dirname, "src"),
entry: "./js/index.js",
output: {
path: __dirname + "/dist/js",
filename: "bundle.min.js"
},
module: {
loaders: [{
test: /\.js?$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
presets: ['es2015'],
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(html)$/,
use: [{
loader: 'html-loader',
options: {
attrs: ['data:src', 'img:src']
}
}]
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: '../img/',
publicPath: '../img/'
}
}]
},
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
mangle: false,
sourcemap: false
}),
new HtmlWebpackPlugin({
filename: '../index.html',
template: './index.html'
}),
],
};