0
点赞
收藏
分享

微信扫一扫

C++列表实现

进击的包籽 2024-05-15 阅读 14

优化前

webpack.config.js

const config = {
    entry: './src/index.js',
    output: {
        filename: 'main.js'
    },
  mode: 'development',
}

module.exports = config;
src/index.js
import $ from 'jquery'
$(document).ready(() => {
    $('body').css({
        width: '100%',
        height: '100%',
        'background-color': 'red'
    })
})

在这里插入图片描述

优化后

webpack.config.js

const HtmlWebpackPlugin = require('html-webpack-plugin');

const config = {
    entry: './src/index.js',
    output: {
        filename: 'main.js'
    },
  mode: 'development',
  externals: {
    $: 'jQuery'
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './index.html',
  })
  ]
}

module.exports = config;
src/index.js
$(document).ready(() => {
    $('body').css({
        width: '100%',
        height: '100%',
        'background-color': 'red'
    })
})
index.html
<!DOCTYPE html>
<html lang="en">
<body>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
</body>
</html>

在这里插入图片描述

举报

相关推荐

0 条评论