• webpack 入门三 打包css、图片、静态资源


    //搭建环境------------------------------------------------------------
    //package.json文件
    npm init
    
    //安装webpack
    npm install webpack -g
    npm install webpack-cli -g
    
    //插件
    npm install html-webpack-plugin --save-dev
    npm install css-loader style-loader --save-dev
    npm install file-loader --save-dev
    npm install url-loader --save-dev
    npm install copy-webpack-plugin --save-dev
    npm install clean-webpack-plugin --save-dev
    //简单打包 webpack ./a.js ./bundle.js //配置打包 webpack --config webpack.config.js

    webpack.config.js

    const HtmlWebpackPlugin = require('html-webpack-plugin');
    const CopyPlugin = require("copy-webpack-plugin");
    const {CleanWebpackPlugin} = require("clean-webpack-plugin");

    var path = require('path');


    module.exports = {
    entry: './main.js',
    output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'app.js'
    },
    module: {
    rules: [
    {
    test: /.css$/i,
    use: ["style-loader", "css-loader"],
    },
    {
    test: /.(png|jpg|gif)$/i,
    use: [
    {
    loader: 'url-loader',
    options: {
    limit: 8192,
    },
    },
    ],
    },
    ],
    },
    plugins: [
            new CleanWebpackPlugin(),
            new HtmlWebpackPlugin({
    title: 'Custom template',
    // Load a custom template (lodash by default)
    template: 'index.html'
    })
    ]
    };

     

     

    天生我材必有用,千金散尽还复来
  • 相关阅读:
    4.数据库表相关操作
    2.快速创建springboot项目 连pom文件里面的配置都不用配了
    1.开始Springboot 基本配置和helloworld
    mysql 对数据库操作的常用sql语句
    mysql简单操作
    1.开始Spring
    关于java中的异常
    关于maven
    npm相关知识点
    git源代码管理工具操作步骤
  • 原文地址:https://www.cnblogs.com/ligenyun/p/14379760.html
Copyright © 2020-2023  润新知