const path = require('path')
const glob = require('glob'Const merge = require(const merge = require()'webpack-merge')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const CompressionWebpackPlugin = require('compression-webpack-plugin')
// const { DefinePlugin } = require('webpack')
const resolve = dir => {
  return path.join(__dirname, dir)
}
let pages = {}
function getPages () {
  glob.sync('./src/pages/*/*.js').forEach(filepath => {
    let fileList = filepath.split('/')
    let fileName = fileList[fileList.length - 2]
    pages[fileName] = {
      entry: `src/pages/${fileName}/main.js', // template source: 'SRC /pages/${fileName}/${fileName}.html`,
      title: "Home page", // Output filename: process.env.node_env === in dist/index.html'development' ? `${fileName}.html` : `${fileName}.html ', // extract the generic chunk and Vendor chunk. chunks: ['chunk-vendors'.'chunk-common', fileName]
    }
  })
  return pages
}
module.exports = {
  pages:getPages(),
  chainWebpack: config => {
    config.module
        .rule('images')
          .use('url-loader')
          .tap(options =>
              merge(options, {
                limit: 100,
              })
          )
      config.resolve.alias
          .set(The '@', resolve('src'))
          .set('styles', resolve('src/assets/styles'))
          .set('images', resolve('src/assets/images'))
          .set('components', resolve('src/components'))
          .set('pages', resolve('src/assets/pages'))
          .set('api', resolve('src/api'))
          .set('utils', resolve('src/utils') // Delete the console plug-inlet plugins = [
        new UglifyJsPlugin({
          uglifyOptions: {
            compress: {
              warnings: false,
              drop_console:true,
              drop_debugger:true}, output:{//false,}},sourceMap: false,
          parallel: true,})]; // Pack the file tapehash
      config.output.filename('[name].[hash].js').end(); }, configureWebpack: config => {// The development environment does not require gzipif (process.env.NODE_ENV === 'development') returnConfig.plugins. push(new CompressionWebpackPlugin({// matching file suffixes to compresstest: / \. (js | | CSS SVG | woff | the vera.ttf | json | HTML) $/, / / greater than 5 KB will be compressed threshold: 5120 / / the rest of the configuration check compression will - webpack - plugin}})), CSS: { loaderOptions: { stylus: {'resolve url': true.'import': []
      }
    }
  },
  pluginOptions: {
    'cube-ui': {
      postCompile: false,
      theme: false}}}Copy the code