vue-cli3创建的项目中,默认集成的 webpack 配置

直接上代码

vue-cli3 创建好的项目,已经帮我们做了下面的事情

  1. 通过「mini-css-extract-plugin」将 css 打包成单个文件
  2. 添加「@」别名,指向「src」目录
  3. 通过「TerserWebpackPlugin」来压缩 js 代码
  4. 在打包时,将引入的第三方插件或库,打包到「chunk-vendors」中

查看项目中的默认 webpack 配置,执行下面的命令

vue inspect > output.js

打开「output.js」文件就能看到下面的内容了

{
     
  mode: 'development',
  context: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack',
  node: {
     
    setImmediate: false,
    process: 'mock',
    dgram: 'empty',
    fs: 'empty',
    net: 'empty',
    tls: 'empty',
    child_process: 'empty'
  },
  output: {
     
  	// 打包输出目录
    path: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/dist',
    // entry 的名字
    filename: 'js/[name].js',
    // This option specifies the public URL of the output directory when referenced in a browser.
    publicPath: '/',
    // chunk 的名字
    chunkFilename: 'js/[name].js'
  },
  resolve: {
     
    alias: {
     
      // 开发中通过 @ 即代表 src 目录下, 例: import name from '@/components/name'
      '@': '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/src',
      // 精确匹配 vue 实例 ,例: import Vue from 'vue'; 精确匹配,所以 vue/dist/vue.runtime.esm.js 被解析和导入
      vue$: 'vue/dist/vue.runtime.esm.js'
    },
    extensions: [ // 自动解析确定的扩展,能够使用户在引入模块时不带扩展,例:import File from '../path/to/file'
      '.mjs',
      '.js',
      '.jsx',
      '.vue',
      '.json',
      '.wasm'
    ],
    modules: [ // 告诉 webpack 解析模块时应该搜索的目录
      'node_modules',
      '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules',
      '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/@vue/cli-service/node_modules'
    ],
    plugins: [
      /* config.resolve.plugin('pnp') */
      {
     }
    ]
  },
  resolveLoader: {
      // 这组选项与上面的 resolve 对象的属性集合相同,但仅用于解析 webpack 的 loader 包
    modules: [
      '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/@vue/cli-plugin-babel/node_modules',
      'node_modules',
      '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules',
      '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/@vue/cli-service/node_modules'
    ],
    plugins: [
      /* config.resolve.plugin('pnp-loaders') */
      {
     }
    ]
  },
  module: {
     
    // 防止 webpack 解析那些任何与给定正则表达式相匹配的文件
    noParse: /^(vue|vue-router|vuex|vuex-router-sync)$/,
    rules: [ // 配置各文件类型的 loader
      /* config.module.rule('vue') */
      {
     
        test: /\.vue$/,
        use: [
          /* config.module.rule('vue').use('cache-loader') */
          {
     
            loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/cache-loader/dist/cjs.js',
            options: {
     
              cacheDirectory: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/.cache/vue-loader',
              cacheIdentifier: '683b501a'
            }
          },
          /* config.module.rule('vue').use('vue-loader') */
          {
     
            loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-loader/lib/index.js',
            options: {
     
              compilerOptions: {
     
                whitespace: 'condense'
              },
              cacheDirectory: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/.cache/vue-loader',
              cacheIdentifier: '683b501a'
            }
          }
        ]
      },
      /* config.module.rule('images') */
      {
     
        test: /\.(png|jpe?g|gif|webp)(\?.*)?$/,
        use: [
          /* config.module.rule('images').use('url-loader') */
          {
     
            loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/url-loader/dist/cjs.js',
            options: {
     
              limit: 4096,
              fallback: {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/file-loader/dist/cjs.js',
                options: {
     
                  name: 'img/[name].[hash:8].[ext]'
                }
              }
            }
          }
        ]
      },
      /* config.module.rule('svg') */
      {
     
        test: /\.(svg)(\?.*)?$/,
        use: [
          /* config.module.rule('svg').use('file-loader') */
          {
     
            loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/file-loader/dist/cjs.js',
            options: {
     
              name: 'img/[name].[hash:8].[ext]'
            }
          }
        ]
      },
      /* config.module.rule('media') */
      {
     
        test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
        use: [
          /* config.module.rule('media').use('url-loader') */
          {
     
            loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/url-loader/dist/cjs.js',
            options: {
     
              limit: 4096,
              fallback: {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/file-loader/dist/cjs.js',
                options: {
     
                  name: 'media/[name].[hash:8].[ext]'
                }
              }
            }
          }
        ]
      },
      /* config.module.rule('fonts') */
      {
     
        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/i,
        use: [
          /* config.module.rule('fonts').use('url-loader') */
          {
     
            loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/url-loader/dist/cjs.js',
            options: {
     
              limit: 4096,
              fallback: {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/file-loader/dist/cjs.js',
                options: {
     
                  name: 'fonts/[name].[hash:8].[ext]'
                }
              }
            }
          }
        ]
      },
      /* config.module.rule('pug') */
      {
     
        test: /\.pug$/,
        oneOf: [
          /* config.module.rule('pug').oneOf('pug-vue') */
          {
     
            resourceQuery: /vue/,
            use: [
              /* config.module.rule('pug').oneOf('pug-vue').use('pug-plain-loader') */
              {
     
                loader: 'pug-plain-loader'
              }
            ]
          },
          /* config.module.rule('pug').oneOf('pug-template') */
          {
     
            use: [
              /* config.module.rule('pug').oneOf('pug-template').use('raw') */
              {
     
                loader: 'raw-loader'
              },
              /* config.module.rule('pug').oneOf('pug-template').use('pug-plain-loader') */
              {
     
                loader: 'pug-plain-loader'
              }
            ]
          }
        ]
      },
      /* config.module.rule('css') */
      {
     
        test: /\.css$/,
        oneOf: [
          /* config.module.rule('css').oneOf('vue-modules') */
          {
     
            resourceQuery: /module/,
            use: [
              /* config.module.rule('css').oneOf('vue-modules').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('css').oneOf('vue-modules').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2,
                  modules: {
     
                    localIdentName: '[name]_[local]_[hash:base64:5]'
                  }
                }
              },
              /* config.module.rule('css').oneOf('vue-modules').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              }
            ]
          },
          /* config.module.rule('css').oneOf('vue') */
          {
     
            resourceQuery: /\?vue/,
            use: [
              /* config.module.rule('css').oneOf('vue').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('css').oneOf('vue').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2
                }
              },
              /* config.module.rule('css').oneOf('vue').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              }
            ]
          },
          /* config.module.rule('css').oneOf('normal-modules') */
          {
     
            test: /\.module\.\w+$/,
            use: [
              /* config.module.rule('css').oneOf('normal-modules').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('css').oneOf('normal-modules').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2,
                  modules: {
     
                    localIdentName: '[name]_[local]_[hash:base64:5]'
                  }
                }
              },
              /* config.module.rule('css').oneOf('normal-modules').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              }
            ]
          },
          /* config.module.rule('css').oneOf('normal') */
          {
     
            use: [
              /* config.module.rule('css').oneOf('normal').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('css').oneOf('normal').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2
                }
              },
              /* config.module.rule('css').oneOf('normal').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              }
            ]
          }
        ]
      },
      /* config.module.rule('postcss') */
      {
     
        test: /\.p(ost)?css$/,
        oneOf: [
          /* config.module.rule('postcss').oneOf('vue-modules') */
          {
     
            resourceQuery: /module/,
            use: [
              /* config.module.rule('postcss').oneOf('vue-modules').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('postcss').oneOf('vue-modules').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2,
                  modules: {
     
                    localIdentName: '[name]_[local]_[hash:base64:5]'
                  }
                }
              },
              /* config.module.rule('postcss').oneOf('vue-modules').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              }
            ]
          },
          /* config.module.rule('postcss').oneOf('vue') */
          {
     
            resourceQuery: /\?vue/,
            use: [
              /* config.module.rule('postcss').oneOf('vue').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('postcss').oneOf('vue').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2
                }
              },
              /* config.module.rule('postcss').oneOf('vue').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              }
            ]
          },
          /* config.module.rule('postcss').oneOf('normal-modules') */
          {
     
            test: /\.module\.\w+$/,
            use: [
              /* config.module.rule('postcss').oneOf('normal-modules').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('postcss').oneOf('normal-modules').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2,
                  modules: {
     
                    localIdentName: '[name]_[local]_[hash:base64:5]'
                  }
                }
              },
              /* config.module.rule('postcss').oneOf('normal-modules').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              }
            ]
          },
          /* config.module.rule('postcss').oneOf('normal') */
          {
     
            use: [
              /* config.module.rule('postcss').oneOf('normal').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('postcss').oneOf('normal').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2
                }
              },
              /* config.module.rule('postcss').oneOf('normal').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              }
            ]
          }
        ]
      },
      /* config.module.rule('scss') */
      {
     
        test: /\.scss$/,
        oneOf: [
          /* config.module.rule('scss').oneOf('vue-modules') */
          {
     
            resourceQuery: /module/,
            use: [
              /* config.module.rule('scss').oneOf('vue-modules').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('scss').oneOf('vue-modules').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2,
                  modules: {
     
                    localIdentName: '[name]_[local]_[hash:base64:5]'
                  }
                }
              },
              /* config.module.rule('scss').oneOf('vue-modules').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('scss').oneOf('vue-modules').use('sass-loader') */
              {
     
                loader: 'sass-loader',
                options: {
     
                  sourceMap: false
                }
              }
            ]
          },
          /* config.module.rule('scss').oneOf('vue') */
          {
     
            resourceQuery: /\?vue/,
            use: [
              /* config.module.rule('scss').oneOf('vue').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('scss').oneOf('vue').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2
                }
              },
              /* config.module.rule('scss').oneOf('vue').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('scss').oneOf('vue').use('sass-loader') */
              {
     
                loader: 'sass-loader',
                options: {
     
                  sourceMap: false
                }
              }
            ]
          },
          /* config.module.rule('scss').oneOf('normal-modules') */
          {
     
            test: /\.module\.\w+$/,
            use: [
              /* config.module.rule('scss').oneOf('normal-modules').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('scss').oneOf('normal-modules').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2,
                  modules: {
     
                    localIdentName: '[name]_[local]_[hash:base64:5]'
                  }
                }
              },
              /* config.module.rule('scss').oneOf('normal-modules').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('scss').oneOf('normal-modules').use('sass-loader') */
              {
     
                loader: 'sass-loader',
                options: {
     
                  sourceMap: false
                }
              }
            ]
          },
          /* config.module.rule('scss').oneOf('normal') */
          {
     
            use: [
              /* config.module.rule('scss').oneOf('normal').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('scss').oneOf('normal').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2
                }
              },
              /* config.module.rule('scss').oneOf('normal').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('scss').oneOf('normal').use('sass-loader') */
              {
     
                loader: 'sass-loader',
                options: {
     
                  sourceMap: false
                }
              }
            ]
          }
        ]
      },
      /* config.module.rule('sass') */
      {
     
        test: /\.sass$/,
        oneOf: [
          /* config.module.rule('sass').oneOf('vue-modules') */
          {
     
            resourceQuery: /module/,
            use: [
              /* config.module.rule('sass').oneOf('vue-modules').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('sass').oneOf('vue-modules').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2,
                  modules: {
     
                    localIdentName: '[name]_[local]_[hash:base64:5]'
                  }
                }
              },
              /* config.module.rule('sass').oneOf('vue-modules').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('sass').oneOf('vue-modules').use('sass-loader') */
              {
     
                loader: 'sass-loader',
                options: {
     
                  sourceMap: false,
                  sassOptions: {
     
                    indentedSyntax: true
                  }
                }
              }
            ]
          },
          /* config.module.rule('sass').oneOf('vue') */
          {
     
            resourceQuery: /\?vue/,
            use: [
              /* config.module.rule('sass').oneOf('vue').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('sass').oneOf('vue').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2
                }
              },
              /* config.module.rule('sass').oneOf('vue').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('sass').oneOf('vue').use('sass-loader') */
              {
     
                loader: 'sass-loader',
                options: {
     
                  sourceMap: false,
                  sassOptions: {
     
                    indentedSyntax: true
                  }
                }
              }
            ]
          },
          /* config.module.rule('sass').oneOf('normal-modules') */
          {
     
            test: /\.module\.\w+$/,
            use: [
              /* config.module.rule('sass').oneOf('normal-modules').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('sass').oneOf('normal-modules').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2,
                  modules: {
     
                    localIdentName: '[name]_[local]_[hash:base64:5]'
                  }
                }
              },
              /* config.module.rule('sass').oneOf('normal-modules').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('sass').oneOf('normal-modules').use('sass-loader') */
              {
     
                loader: 'sass-loader',
                options: {
     
                  sourceMap: false,
                  sassOptions: {
     
                    indentedSyntax: true
                  }
                }
              }
            ]
          },
          /* config.module.rule('sass').oneOf('normal') */
          {
     
            use: [
              /* config.module.rule('sass').oneOf('normal').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('sass').oneOf('normal').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2
                }
              },
              /* config.module.rule('sass').oneOf('normal').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('sass').oneOf('normal').use('sass-loader') */
              {
     
                loader: 'sass-loader',
                options: {
     
                  sourceMap: false,
                  sassOptions: {
     
                    indentedSyntax: true
                  }
                }
              }
            ]
          }
        ]
      },
      /* config.module.rule('less') */
      {
     
        test: /\.less$/,
        oneOf: [
          /* config.module.rule('less').oneOf('vue-modules') */
          {
     
            resourceQuery: /module/,
            use: [
              /* config.module.rule('less').oneOf('vue-modules').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('less').oneOf('vue-modules').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2,
                  modules: {
     
                    localIdentName: '[name]_[local]_[hash:base64:5]'
                  }
                }
              },
              /* config.module.rule('less').oneOf('vue-modules').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('less').oneOf('vue-modules').use('less-loader') */
              {
     
                loader: 'less-loader',
                options: {
     
                  sourceMap: false
                }
              }
            ]
          },
          /* config.module.rule('less').oneOf('vue') */
          {
     
            resourceQuery: /\?vue/,
            use: [
              /* config.module.rule('less').oneOf('vue').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('less').oneOf('vue').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2
                }
              },
              /* config.module.rule('less').oneOf('vue').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('less').oneOf('vue').use('less-loader') */
              {
     
                loader: 'less-loader',
                options: {
     
                  sourceMap: false
                }
              }
            ]
          },
          /* config.module.rule('less').oneOf('normal-modules') */
          {
     
            test: /\.module\.\w+$/,
            use: [
              /* config.module.rule('less').oneOf('normal-modules').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('less').oneOf('normal-modules').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2,
                  modules: {
     
                    localIdentName: '[name]_[local]_[hash:base64:5]'
                  }
                }
              },
              /* config.module.rule('less').oneOf('normal-modules').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('less').oneOf('normal-modules').use('less-loader') */
              {
     
                loader: 'less-loader',
                options: {
     
                  sourceMap: false
                }
              }
            ]
          },
          /* config.module.rule('less').oneOf('normal') */
          {
     
            use: [
              /* config.module.rule('less').oneOf('normal').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('less').oneOf('normal').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2
                }
              },
              /* config.module.rule('less').oneOf('normal').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('less').oneOf('normal').use('less-loader') */
              {
     
                loader: 'less-loader',
                options: {
     
                  sourceMap: false
                }
              }
            ]
          }
        ]
      },
      /* config.module.rule('stylus') */
      {
     
        test: /\.styl(us)?$/,
        oneOf: [
          /* config.module.rule('stylus').oneOf('vue-modules') */
          {
     
            resourceQuery: /module/,
            use: [
              /* config.module.rule('stylus').oneOf('vue-modules').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('stylus').oneOf('vue-modules').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2,
                  modules: {
     
                    localIdentName: '[name]_[local]_[hash:base64:5]'
                  }
                }
              },
              /* config.module.rule('stylus').oneOf('vue-modules').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('stylus').oneOf('vue-modules').use('stylus-loader') */
              {
     
                loader: 'stylus-loader',
                options: {
     
                  sourceMap: false,
                  preferPathResolver: 'webpack'
                }
              }
            ]
          },
          /* config.module.rule('stylus').oneOf('vue') */
          {
     
            resourceQuery: /\?vue/,
            use: [
              /* config.module.rule('stylus').oneOf('vue').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('stylus').oneOf('vue').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2
                }
              },
              /* config.module.rule('stylus').oneOf('vue').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('stylus').oneOf('vue').use('stylus-loader') */
              {
     
                loader: 'stylus-loader',
                options: {
     
                  sourceMap: false,
                  preferPathResolver: 'webpack'
                }
              }
            ]
          },
          /* config.module.rule('stylus').oneOf('normal-modules') */
          {
     
            test: /\.module\.\w+$/,
            use: [
              /* config.module.rule('stylus').oneOf('normal-modules').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('stylus').oneOf('normal-modules').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2,
                  modules: {
     
                    localIdentName: '[name]_[local]_[hash:base64:5]'
                  }
                }
              },
              /* config.module.rule('stylus').oneOf('normal-modules').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('stylus').oneOf('normal-modules').use('stylus-loader') */
              {
     
                loader: 'stylus-loader',
                options: {
     
                  sourceMap: false,
                  preferPathResolver: 'webpack'
                }
              }
            ]
          },
          /* config.module.rule('stylus').oneOf('normal') */
          {
     
            use: [
              /* config.module.rule('stylus').oneOf('normal').use('vue-style-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/vue-style-loader/index.js',
                options: {
     
                  sourceMap: false,
                  shadowMode: false
                }
              },
              /* config.module.rule('stylus').oneOf('normal').use('css-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/css-loader/dist/cjs.js',
                options: {
     
                  sourceMap: false,
                  importLoaders: 2
                }
              },
              /* config.module.rule('stylus').oneOf('normal').use('postcss-loader') */
              {
     
                loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/postcss-loader/src/index.js',
                options: {
     
                  sourceMap: false,
                  plugins: [
                    function () {
      /* omitted long function */ }
                  ]
                }
              },
              /* config.module.rule('stylus').oneOf('normal').use('stylus-loader') */
              {
     
                loader: 'stylus-loader',
                options: {
     
                  sourceMap: false,
                  preferPathResolver: 'webpack'
                }
              }
            ]
          }
        ]
      },
      /* config.module.rule('js') */
      {
     
        test: /\.m?jsx?$/,
        exclude: [
          function () {
      /* omitted long function */ }
        ],
        use: [
          /* config.module.rule('js').use('cache-loader') */
          {
     
            loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/cache-loader/dist/cjs.js',
            options: {
     
              cacheDirectory: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/.cache/babel-loader',
              cacheIdentifier: 'd6e1672a'
            }
          },
          /* config.module.rule('js').use('babel-loader') */
          {
     
            loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/babel-loader/lib/index.js'
          }
        ]
      },
      /* config.module.rule('eslint') */
      {
     
        enforce: 'pre',
        test: /\.(vue|(j|t)sx?)$/,
        exclude: [
          /node_modules/,
          '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/@vue/cli-service/lib'
        ],
        use: [
          /* config.module.rule('eslint').use('eslint-loader') */
          {
     
            loader: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/eslint-loader/index.js',
            options: {
     
              extensions: [
                '.js',
                '.jsx',
                '.vue'
              ],
              cache: true,
              cacheIdentifier: '2b54db13',
              emitWarning: false,
              emitError: false,
              eslintPath: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/node_modules/eslint',
              formatter: undefined
            }
          }
        ]
      }
    ]
  },
  optimization: {
      // 优化配置
    splitChunks: {
      // 替代 CommonsChunkPlugin
      cacheGroups: {
      // 缓存组
        vendors: {
     
          name: 'chunk-vendors',
          test: /[\\\/]node_modules[\\\/]/,
          priority: -10,
          chunks: 'initial'
        },
        common: {
     
          name: 'chunk-common',
          minChunks: 2,
          priority: -20,
          chunks: 'initial',
          reuseExistingChunk: true
        }
      }
    },
    minimizer: [ // 允许通过提供一个或多个不同的自定义 TerserPlugin 实例来覆盖默认的最小化器
      /* config.optimization.minimizer('terser') */
      new TerserPlugin( // TerserPlugin 提供代码压缩的功能
        {
     
          terserOptions: {
     
            compress: {
     
              arrows: false,
              collapse_vars: false,
              comparisons: false,
              computed_props: false,
              hoist_funs: false,
              hoist_props: false,
              hoist_vars: false,
              inline: false,
              loops: false,
              negate_iife: false,
              properties: false,
              reduce_funcs: false,
              reduce_vars: false,
              switches: false,
              toplevel: false,
              typeofs: false,
              booleans: true,
              if_return: true,
              sequences: true,
              unused: true,
              conditionals: true,
              dead_code: true,
              evaluate: true
            },
            mangle: {
     
              safari10: true
            }
          },
          sourceMap: true,
          cache: true,
          parallel: true,
          extractComments: false
        }
      )
    ]
  },
  plugins: [
    /* config.plugin('vue-loader') */
    new VueLoaderPlugin(), // 定位在 require('vue-loader/lib/plugin')
    /* config.plugin('define') */
    new DefinePlugin( // Defineplugin 允许创建可以在编译时配置的全局常量
      {
     
        'process.env': {
     
          NODE_ENV: '"development"',
          BASE_URL: '"/"'
        }
      }
    ),
    /* config.plugin('case-sensitive-paths') */
    new CaseSensitivePathsPlugin(),
    /* config.plugin('friendly-errors') */
    new FriendlyErrorsWebpackPlugin(
      {
     
        additionalTransformers: [
          function () {
      /* omitted long function */ }
        ],
        additionalFormatters: [
          function () {
      /* omitted long function */ }
        ]
      }
    ),
    /* config.plugin('html') */
    new HtmlWebpackPlugin(
      {
     
        title: 'vue-cli3-webpack',
        templateParameters: function () {
      /* omitted long function */ },
        template: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/public/index.html'
      }
    ),
    /* config.plugin('preload') */
    new PreloadPlugin(
      {
     
        rel: 'preload',
        include: 'initial',
        fileBlacklist: [
          /\.map$/,
          /hot-update\.js$/
        ]
      }
    ),
    /* config.plugin('prefetch') */
    new PreloadPlugin(
      {
     
        rel: 'prefetch',
        include: 'asyncChunks'
      }
    ),
    /* config.plugin('copy') */
    new CopyPlugin( // 将已存在的单个文件或整个目录复制到生成目录
      [
        {
     
          from: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/public',
          to: '/Users/huangyao/Documents/黄遥/learn-and-work/学习和准备/vue-cli3-webpack/dist',
          toType: 'dir',
          ignore: [ // 忽略的内容
            '.DS_Store',
            {
     
              glob: 'index.html',
              matchBase: false
            }
          ]
        }
      ]
    )
  ],
  entry: {
     
    app: [
      './src/main.js'
    ]
  }
}

你可能感兴趣的:(Webpack,webpack)