博客
关于我
webpack中html-webpack-plugin中的模版文件失效
阅读量:169 次
发布时间:2019-02-28

本文共 2017 字,大约阅读时间需要 6 分钟。

html-webpack-plugin?????????????

???html-webpack-plugin???????????????????????ejs???????????????????html-loader????????????????

????

html-webpack-plugin??????html????????????????html-loader????????????

  • ??????????????ejs??????
  • ??????html-loader?????????
  • ????????html-loader??

  • ?????webpack.config.js?????????html-loader
  • ??????????????
  • ??????????html-loader?????????????ejs????????
  • ??????????????????????????html-loader
  • ??????ejs????

  • ????html???????.html.ejs??
  • ?????????html?????????require??
  • ??????ejs???????require?????html-loader!??
  • ?????????html-loader?ejs?????
  • ????

    const { CleanWebpackPlugin } = require('clean-webpack-plugin');
    const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
    const HtmlWebpackPlugin = require('html-webpack-plugin');
    module.exports = {
    entry: {
    index: './src/index.js',
    demo: './src/demo.js',
    main: './src/main.js'
    },
    output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'js/[name].js'
    },
    mode: 'development',
    plugins: [
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
    chunks: ['main', 'index'],
    template: 'index.html',
    filename: 'index.html'
    }),
    new UglifyJsPlugin({
    exclude: /\/main/
    })
    ],
    module: {
    rules: [
    {
    test: /\.(png|jpg|gif)$/,
    use: [{
    loader: 'url-loader',
    options: { esModule: false }
    }]
    },
    {
    test: /\.css$/,
    loader: 'style-loader'
    },
    {
    test: /\.css$/,
    loader: 'css-loader'
    },
    {
    test: /\.html$/,
    loader: 'html-loader'
    }
    ]
    }
    };

    ????

  • ???????????????????????require??
  • ???????????????html?ejs?????????
  • ?????????????????????????????????
  • ?????????????html-webpack-plugin?html-loader??????????????ejs?????????

    转载地址:http://jead.baihongyu.com/

    你可能感兴趣的文章
    nginx 后端获取真实ip
    查看>>
    Nginx 学习总结(17)—— 8 个免费开源 Nginx 管理系统,轻松管理 Nginx 站点配置
    查看>>
    nginx 常用配置记录
    查看>>
    Nginx 我们必须知道的那些事
    查看>>
    Nginx 的 proxy_pass 使用简介
    查看>>
    Nginx 的配置文件中的 keepalive 介绍
    查看>>
    Nginx 负载均衡与权重配置解析
    查看>>
    Nginx 负载均衡详解
    查看>>
    nginx 配置 单页面应用的解决方案
    查看>>
    nginx 配置~~~本身就是一个静态资源的服务器
    查看>>
    Nginx下配置codeigniter框架方法
    查看>>
    nginx添加模块与https支持
    查看>>
    Nginx的Rewrite正则表达式,匹配非某单词
    查看>>
    Nginx的使用总结(一)
    查看>>
    Nginx的是什么?干什么用的?
    查看>>
    Nginx访问控制_登陆权限的控制(http_auth_basic_module)
    查看>>
    nginx负载均衡器处理session共享的几种方法(转)
    查看>>
    nginx负载均衡的5种策略(转载)
    查看>>
    nginx负载均衡的五种算法
    查看>>
    Nginx配置ssl实现https
    查看>>