zoukankan      html  css  js  c++  java
  • webpack(一) 配置

    一、entry  & output

    mode: 'development',
      // entry: './src/index',
      // entry: ['./src/index', './src/pollyfill'],
      entry: {
        app: './src/index',
        pollyfill: './src/pollyfill.js'
      },
      output: {
        filename: '[name].[hash:8].js',
        path: path.resolve(__dirname, 'dist'),
       publicPath: '/', },

     二、resolve

      resolve: {
        extensions: ['.js', '.jsx', '.json'],
        alias: {
          '@': path.join(__dirname, '../', 'src'),
        }
      },

    三、懒加载

    import() 原理是通过jsonp; 返回promise

    const $el = document.createElement('div');
    $el.className ='container';
    $el.addEventListener('click', function(){
      import('./caltTest').then((res)=>{
        console.log(res.default);
      })
    });
    document.body.appendChild($el);

    四、热更新

    devServer中增加hotOnly:true


    五、定义环境变量

    new Webpack.DefinePlugin({
          ENV: 'true',
          // SERVE: "'https://www.baidu.com'",
          UAT: JSON.stringify('uat'),
        }),
  • 相关阅读:
    字符串哈希
    codeforces#766 D. Mahmoud and a Dictionary (并查集)
    莫比乌斯反演模板
    马拉车模板
    codeforces#580 D. Kefa and Dishes(状压dp)
    1076E
    448C
    543A
    295B
    poj3974 Palindrome
  • 原文地址:https://www.cnblogs.com/shangyueyue/p/10702859.html
Copyright © 2011-2022 走看看