0
点赞
收藏
分享

微信扫一扫

webpack优化构建速度-module.noParse

戴老师成长记录仪 2024-05-16 阅读 10
webpack

优化前耗时

webpack.config.js
const config = {
    entry: './src/index.js',
    output: {
        filename: 'main.js'
    },
  mode: 'development',
  module: {
    noParse: (path) => {
      console.log('结果', /jquery|lodash\//.test(path))
      return /jquery|lodash\//.test(path)
    },
  }
}

module.exports = config;
npm i jquery
src/index.js
import $ from 'jquery'

$(document).ready(() => {
    $('body').css({
        width: '100%',
        height: '100%',
        'background-color': 'red'
    })
})

在这里插入图片描述
优化后耗时
在这里插入图片描述

举报

相关推荐

0 条评论