<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      build 文件夾中的 webpack.prod.conf.js

       

        1 // 此文件是生產環境下webpack相關配置
        2 'use strict'
        3 const path = require('path')
        4 const utils = require('./utils')
        5 const webpack = require('webpack')
        6 const config = require('../config') // 引入全局配置
        7 const merge = require('webpack-merge') // webpack-merge插件提供合并功能,將多個對象合并創建一個新對象。
        8 const baseWebpackConfig = require('./webpack.base.conf')
        9 const CopyWebpackPlugin = require('copy-webpack-plugin') // 用來復制
       10 const HtmlWebpackPlugin = require('html-webpack-plugin') // 自動生成html文件
       11 // const ExtractTextPlugin = require('extract-text-webpack-plugin') // 用來抽離css 防止css打包壓縮到js中
       12 const MiniCssExtractPlugin = require('mini-css-extract-plugin') //將css單獨打包成一個文件的插件,它為每個包含css的js文件都創建一個css文件
       13 const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') // 用來壓縮單獨的css文件
       14 const UglifyJsPlugin = require('uglifyjs-webpack-plugin') //用來壓縮
       15 
       16 //導入prod.env.js 用來區分是生產環境
       17 const env = process.env.NODE_ENV === 'testing' ?
       18   require('../config/test.env') :
       19   require('../config/prod.env')
       20 
       21 // 合并
       22 const webpackConfig = merge(baseWebpackConfig, {
       23   mode: 'production',
       24   module: {
       25     // 配置獨立的css文件的解析規則
       26     rules: utils.styleLoaders({
       27       sourceMap: config.build.productionSourceMap,
       28       // 生成獨立的文件
       29       extract: true,
       30       usePostCSS: true
       31     })
       32   },
       33   // 開發工具 用來調試
       34   devtool: config.build.productionSourceMap ? config.build.devtool : false,
       35   // 輸出
       36   output: {
       37     // 打包后的文件放在dist目錄下面
       38     path: config.build.assetsRoot,
       39     // 編譯生成的js文件存放在根目錄下的js目錄下,如果js文件夾不存在就自動創建
       40     filename: utils.assetsPath('js/[name].[chunkhash].js'),
       41     // 用來打包require.ensure方法中引入的模塊,如果該方法中沒有引入任何模塊,就不會生成chunk文件
       42     chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
       43   },
       44   // 優化 (https://webpack.docschina.org/configuration/optimization/)
       45   optimization: {
       46     moduleIds: 'hashed', // 告知 webpack 當選擇模塊 id 時需要使用哪種算法 ( 'hashed' 相應地會在 webpack 5 中廢棄,被 'deterministic' 代替 )
       47     // 拆分模塊 (http://www.rzrgm.cn/kwzm/p/10314438.html)
       48     splitChunks: {
       49       chunks: 'async', // 選擇用于確定共享模塊的塊(默認為“async”、“initial”和“all”需要將這些塊添加到HTML中)
       50       minSize: 30000, // 創建塊的大小
       51       // minRemainingSize: 0,
       52       maxSize: 0,
       53       minChunks: 1,
       54       maxAsyncRequests: 6,
       55       maxInitialRequests: 4,
       56       automaticNameDelimiter: '~',
       57       cacheGroups: {
       58         defaultVendors: {
       59           test: /[\\/]node_modules[\\/]/,
       60           priority: -10
       61         },
       62         default: {
       63           minChunks: 2,
       64           priority: -20,
       65           reuseExistingChunk: true
       66         },
       67         elementUI: {
       68           name: "chunk-elementUI", // 單獨將 elementUI 拆包
       69           priority: 15, // 權重需大于其它緩存組
       70           test: /[\/]node_modules[\/]element-ui[\/]/
       71         }
       72       }
       73     }
       74   },
       75   //配置插件項
       76   plugins: [
       77     // http://vuejs.github.io/vue-loader/en/workflow/production.html
       78     // 自定義一個plugin 生成當前環境下的一個變量
       79     new webpack.DefinePlugin({
       80       'process.env': env
       81     }),
       82     //壓縮
       83     new UglifyJsPlugin({
       84       uglifyOptions: {
       85         // 禁止壓縮警告信息
       86         warnings: false
       87       },
       88       sourceMap: config.build.productionSourceMap, //是否開啟sourceMap 用來調試
       89       parallel: true //在系統的CPU有多于一個內核時自動啟用 僅作用于生產構建
       90     }),
       91     // 將css解壓縮到它自己的文件中
       92     new MiniCssExtractPlugin({
       93       //文件名
       94       filename: utils.assetsPath('css/app.[name].css'),
       95       chunkFilename: utils.assetsPath('css/app.[contenthash:12].css'), // use contenthash *
       96     }),
       97     //壓縮提取CSS。我們使用這個插件,所以可以從不同的組件復制CSS。
       98     new OptimizeCSSPlugin({
       99       cssProcessorOptions: config.build.productionSourceMap ? {
      100         safe: true,
      101         map: {
      102           inline: false
      103         }
      104       } : {
      105         safe: true
      106       }
      107     }),
      108     // generate dist index.html with correct asset hash for caching.
      109     // you can customize output by editing /index.html
      110     // see https://github.com/ampedandwired/html-webpack-plugin
      111     new HtmlWebpackPlugin({
      112       filename: process.env.NODE_ENV === 'testing' ?
      113         'index.html' : config.build.index,
      114       template: 'index.html',
      115       favicon: path.resolve(__dirname, '../static/images/favicon.ico'),
      116       inject: true,
      117       minify: {
      118         removeComments: true,
      119         collapseWhitespace: true,
      120         removeAttributeQuotes: true
      121         // more options:
      122         // https://github.com/kangax/html-minifier#options-quick-reference
      123       },
      124       // necessary to consistently work with multiple chunks via CommonsChunkPlugin
      125       chunksSortMode: 'manual',
      126       dll: (function () {
      127         let max = 2
      128         let res = []
      129         for (let i = 0; i < max; i++) {
      130           const dllName = require(path.resolve(__dirname, `../dllManifest/xuAdmin${i}-manifest.json`)).name.split('_')
      131           res.push(`./static/dll/${dllName[0]}.${dllName[1]}.dll.js`)
      132         }
      133         return res
      134       })()
      135     }),
      136     // keep module.id stable when vendor modules does not change
      137     new webpack.HashedModuleIdsPlugin(),
      138     // enable scope hoisting
      139     new webpack.optimize.ModuleConcatenationPlugin(),
      140     // split vendor js into its own file
      141 
      142     // extract webpack runtime and module manifest to its own file in order to
      143     // prevent vendor hash from being updated whenever app bundle is updated
      144 
      145     // This instance extracts shared chunks from code splitted chunks and bundles them
      146     // in a separate chunk, similar to the vendor chunk
      147     // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
      148 
      149 
      150     // 復制自定義靜態資產
      151     new CopyWebpackPlugin([{
      152       from: path.resolve(__dirname, '../static'),
      153       to: config.build.assetsSubDirectory,
      154       ignore: ['.*']
      155     }]),
      156   ]
      157 })
      158 
      159 
      160 //壓縮
      161 if (config.build.productionGzip) {
      162   const CompressionWebpackPlugin = require('compression-webpack-plugin')
      163 
      164   webpackConfig.plugins.push(
      165     new CompressionWebpackPlugin({
      166       asset: '[path].gz[query]', // 目標資源名稱 [path]會被替換成原始資源的路徑 [query]會被替換成查詢字符串
      167       algorithm: 'gzip', // 按照zlib的算法
      168       // 所有匹配該正則的資源都會被處理 默認值是全部資源
      169       test: new RegExp(
      170         '\\.(' +
      171         config.build.productionGzipExtensions.join('|') +
      172         ')$'
      173       ),
      174       threshold: 10240, // 只有大小大于該值得資源會被處理,單位是bytes
      175       minRatio: 0.8 // 壓縮率小于這個值得資源才會被處理 默認值是 0.8
      176     })
      177   )
      178 }
      179 
      180 //打包文件分析工具
      181 if (config.build.bundleAnalyzerReport) {
      182   const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
      183   webpackConfig.plugins.push(new BundleAnalyzerPlugin())
      184 }
      185 
      186 //導出
      187 module.exports = webpackConfig
      188 // 此文件是生產環境下webpack相關配置
      189 'use strict'
      190 const path = require('path')
      191 const utils = require('./utils')
      192 const webpack = require('webpack')
      193 const config = require('../config') // 引入全局配置
      194 const merge = require('webpack-merge') // webpack-merge插件提供合并功能,將多個對象合并創建一個新對象。
      195 const baseWebpackConfig = require('./webpack.base.conf')
      196 const CopyWebpackPlugin = require('copy-webpack-plugin') // 用來復制
      197 const HtmlWebpackPlugin = require('html-webpack-plugin') // 自動生成html文件
      198 // const ExtractTextPlugin = require('extract-text-webpack-plugin') // 用來抽離css 防止css打包壓縮到js中
      199 const MiniCssExtractPlugin = require('mini-css-extract-plugin') //將css單獨打包成一個文件的插件,它為每個包含css的js文件都創建一個css文件
      200 const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') // 用來壓縮單獨的css文件
      201 const UglifyJsPlugin = require('uglifyjs-webpack-plugin') //用來壓縮
      202 
      203 //導入prod.env.js 用來區分是生產環境
      204 const env = process.env.NODE_ENV === 'testing' ?
      205   require('../config/test.env') :
      206   require('../config/prod.env')
      207 
      208 // 合并
      209 const webpackConfig = merge(baseWebpackConfig, {
      210   mode: 'production',
      211   module: {
      212     // 配置獨立的css文件的解析規則
      213     rules: utils.styleLoaders({
      214       sourceMap: config.build.productionSourceMap,
      215       // 生成獨立的文件
      216       extract: true,
      217       usePostCSS: true
      218     })
      219   },
      220   // 開發工具 用來調試
      221   devtool: config.build.productionSourceMap ? config.build.devtool : false,
      222   // 輸出
      223   output: {
      224     // 打包后的文件放在dist目錄下面
      225     path: config.build.assetsRoot,
      226     // 編譯生成的js文件存放在根目錄下的js目錄下,如果js文件夾不存在就自動創建
      227     filename: utils.assetsPath('js/[name].[chunkhash].js'),
      228     // 用來打包require.ensure方法中引入的模塊,如果該方法中沒有引入任何模塊,就不會生成chunk文件
      229     chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
      230   },
      231   // 優化 (https://webpack.docschina.org/configuration/optimization/)
      232   optimization: {
      233     moduleIds: 'hashed', // 告知 webpack 當選擇模塊 id 時需要使用哪種算法 ( 'hashed' 相應地會在 webpack 5 中廢棄,被 'deterministic' 代替 )
      234     // 拆分模塊 (http://www.rzrgm.cn/kwzm/p/10314438.html)
      235     splitChunks: {
      236       chunks: 'async', // 選擇用于確定共享模塊的塊(默認為“async”、“initial”和“all”需要將這些塊添加到HTML中)
      237       minSize: 30000, // 創建塊的大小
      238       // minRemainingSize: 0,
      239       maxSize: 0,
      240       minChunks: 1,
      241       maxAsyncRequests: 6,
      242       maxInitialRequests: 4,
      243       automaticNameDelimiter: '~',
      244       cacheGroups: {
      245         defaultVendors: {
      246           test: /[\\/]node_modules[\\/]/,
      247           priority: -10
      248         },
      249         default: {
      250           minChunks: 2,
      251           priority: -20,
      252           reuseExistingChunk: true
      253         },
      254         elementUI: {
      255           name: "chunk-elementUI", // 單獨將 elementUI 拆包
      256           priority: 15, // 權重需大于其它緩存組
      257           test: /[\/]node_modules[\/]element-ui[\/]/
      258         }
      259       }
      260     }
      261   },
      262   //配置插件項
      263   plugins: [
      264     // http://vuejs.github.io/vue-loader/en/workflow/production.html
      265     // 自定義一個plugin 生成當前環境下的一個變量
      266     new webpack.DefinePlugin({
      267       'process.env': env
      268     }),
      269     //壓縮
      270     new UglifyJsPlugin({
      271       uglifyOptions: {
      272         // 禁止壓縮警告信息
      273         warnings: false
      274       },
      275       sourceMap: config.build.productionSourceMap, //是否開啟sourceMap 用來調試
      276       parallel: true //在系統的CPU有多于一個內核時自動啟用 僅作用于生產構建
      277     }),
      278     // 將css解壓縮到它自己的文件中
      279     new MiniCssExtractPlugin({
      280       //文件名
      281       filename: utils.assetsPath('css/app.[name].css'),
      282       chunkFilename: utils.assetsPath('css/app.[contenthash:12].css'), // use contenthash *
      283     }),
      284     //壓縮提取CSS。我們使用這個插件,所以可以從不同的組件復制CSS。
      285     new OptimizeCSSPlugin({
      286       cssProcessorOptions: config.build.productionSourceMap ? {
      287         safe: true,
      288         map: {
      289           inline: false
      290         }
      291       } : {
      292         safe: true
      293       }
      294     }),
      295     // generate dist index.html with correct asset hash for caching.
      296     // you can customize output by editing /index.html
      297     // see https://github.com/ampedandwired/html-webpack-plugin
      298     new HtmlWebpackPlugin({
      299       filename: process.env.NODE_ENV === 'testing' ?
      300         'index.html' : config.build.index,
      301       template: 'index.html',
      302       favicon: path.resolve(__dirname, '../static/images/favicon.ico'),
      303       inject: true,
      304       minify: {
      305         removeComments: true,
      306         collapseWhitespace: true,
      307         removeAttributeQuotes: true
      308         // more options:
      309         // https://github.com/kangax/html-minifier#options-quick-reference
      310       },
      311       // necessary to consistently work with multiple chunks via CommonsChunkPlugin
      312       chunksSortMode: 'manual',
      313       dll: (function () {
      314         let max = 2
      315         let res = []
      316         for (let i = 0; i < max; i++) {
      317           const dllName = require(path.resolve(__dirname, `../dllManifest/xuAdmin${i}-manifest.json`)).name.split('_')
      318           res.push(`./static/dll/${dllName[0]}.${dllName[1]}.dll.js`)
      319         }
      320         return res
      321       })()
      322     }),
      323     // keep module.id stable when vendor modules does not change
      324     new webpack.HashedModuleIdsPlugin(),
      325     // enable scope hoisting
      326     new webpack.optimize.ModuleConcatenationPlugin(),
      327     // split vendor js into its own file
      328 
      329     // extract webpack runtime and module manifest to its own file in order to
      330     // prevent vendor hash from being updated whenever app bundle is updated
      331 
      332     // This instance extracts shared chunks from code splitted chunks and bundles them
      333     // in a separate chunk, similar to the vendor chunk
      334     // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
      335 
      336 
      337     // 復制自定義靜態資產
      338     new CopyWebpackPlugin([{
      339       from: path.resolve(__dirname, '../static'),
      340       to: config.build.assetsSubDirectory,
      341       ignore: ['.*']
      342     }]),
      343   ]
      344 })
      345 
      346 
      347 //壓縮
      348 if (config.build.productionGzip) {
      349   const CompressionWebpackPlugin = require('compression-webpack-plugin')
      350 
      351   webpackConfig.plugins.push(
      352     new CompressionWebpackPlugin({
      353       asset: '[path].gz[query]', // 目標資源名稱 [path]會被替換成原始資源的路徑 [query]會被替換成查詢字符串
      354       algorithm: 'gzip', // 按照zlib的算法
      355       // 所有匹配該正則的資源都會被處理 默認值是全部資源
      356       test: new RegExp(
      357         '\\.(' +
      358         config.build.productionGzipExtensions.join('|') +
      359         ')$'
      360       ),
      361       threshold: 10240, // 只有大小大于該值得資源會被處理,單位是bytes
      362       minRatio: 0.8 // 壓縮率小于這個值得資源才會被處理 默認值是 0.8
      363     })
      364   )
      365 }
      366 
      367 //打包文件分析工具
      368 if (config.build.bundleAnalyzerReport) {
      369   const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
      370   webpackConfig.plugins.push(new BundleAnalyzerPlugin())
      371 }
      372 
      373 //導出
      374 module.exports = webpackConfig

       

      posted @ 2020-12-02 16:37  思猿客  閱讀(298)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 成人精品视频一区二区三区尤物| 视频一区二区三区高清在线| 无码人妻丰满熟妇区毛片18| 浙江省| 国产午夜精品福利免费看| 强插少妇视频一区二区三区| 强d乱码中文字幕熟女1000部| 久久99热只有频精品8| 成人午夜视频一区二区无码| 日韩精品国产二区三区| 久久婷婷五月综合97色直播| 久播影院无码中文字幕| 亚洲狠狠狠一区二区三区| 一本色道婷婷久久欧美| 色老头亚洲成人免费影院| av激情亚洲男人的天堂| 日韩在线观看中文字幕| 性一交一乱一伦一| 在线观看热码亚洲av每日更新| 欧美在线人视频在线观看| 乐东| 无码一区二区三区视频| 精品偷拍一区二区三区| 国产69久久精品成人看| 亚洲国产欧美在线人成aaaa| 好男人官网资源在线观看| 性色av蜜臀av色欲av| 亚洲国产午夜精品理论片| 久热这里只有精品12| 国产精欧美一区二区三区| 深夜免费av在线观看| 无码囯产精品一区二区免费| 久久精品国产亚洲夜色av网站| 成人免费无码av| 亚洲欧洲日产国无高清码图片| 国产精品无码一区二区桃花视频| 国产一区二区亚洲一区二区三区| 一区二区三区国产综合在线| 亚洲人成网站在线播放2019| 国产热A欧美热A在线视频| 国内精品久久久久影院网站|