美文网首页
处理html中的图片

处理html中的图片

作者: visitor009 | 来源:发表于2018-09-25 10:38 被阅读0次
$_> npm i -D file-loader html-loader
// webpack.config.js
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: {
        index: './src/index.js',
        util: './src/util.js',
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: '[name].bundle.js',
    },
    module: {
        rules: [{
            test: /\.(css)$/,
            use: ['style-loader','css-loader']
        },{
            test: /\.(jpeg|png|jpg)$/,
            use: {loader:'file-loader',
            options: {
                outputPath: 'assets/imgs/',
            }
        }
        },{
            test: /\.(html)$/,
            use: {loader: 'html-loader'}
            
        }]
    },
    plugins: [
        new HtmlWebpackPlugin({
            filename: 'index.html',
            template: './src/html/index.html',
            inject: 'body',
            chunks: ['index']    
        })
    ],
    mode: 'development'
};
捕获.JPG

相关文章

    本文标题:处理html中的图片

    本文链接:https://www.haomeiwen.com/subject/vvpkoftx.html