text: /*
   * Copyright (c) 2019 The StreamX Project
   * <p>
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements. See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership. The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
   * with the License. You may obtain a copy of the License at
   * <p>
   * http://www.apache.org/licenses/LICENSE-2.0
   * <p>
   * Unless required by applicable law or agreed to in writing,
   * software distributed under the License is distributed on an
   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   * KIND, either express or implied. See the License for the
   * specific language governing permissions and limitations
   * under the License.
   */
  
  const path = require('path')
  const webpack = require('webpack')
  const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin')
  
  const ThemeColorReplacer = require('webpack-theme-color-replacer')
  const {getThemeColors, modifyVars} = require('./src/utils/themeUtil')
  const {resolveCss} = require('./src/utils/theme-color-replacer-extend')
  const isProd = process.env.NODE_ENV === 'production'
  
  
  function resolve (dir) {
    return path.join(__dirname, dir)
  }
  
  // vue.config.js
  module.exports = {
  
    devServer: {
      // development server port 8000
      port: 10000,
      proxy: {
        '/api/!*': {
          target: 'http://test-hadoop-1:10000',
          ws: false,
          changeOrigin: true,
          pathRewrite: { '^/api': '' }
        }
      }
    },
  
    pluginOptions: {
      'style-resources-loader': {
        preProcessor: 'less',
        patterns: [path.resolve(__dirname, './src/theme/theme.less')],
      }
    },
  
    configureWebpack: {
  
      resolve : {
        alias: {
          'jQuery':	path.join(__dirname, 'node_modules', 'jquery')
        }
      },
  
      plugins: [
        // Ignore all locale files of moment.js
        new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
        new webpack.ProvidePlugin({
          $: 'jquery',
          jQuery: 'jquery',
          'windows.jQuery': 'jquery',
        }),
        new MonacoWebpackPlugin(),
        new ThemeColorReplacer({
          fileName: 'css/theme-colors-[contenthash:8].css',
          matchColors: getThemeColors(),
          injectCss: true,
          resolveCss
        })
      ]
    },
  
    chainWebpack: (config) => {
      config.resolve.alias
        .set('@$', resolve('src'))
        .set('@api', resolve('src/api'))
        .set('@assets', resolve('src/assets'))
        .set('@comp', resolve('src/components'))
        .set('@views', resolve('src/views'))
        .set('@layout', resolve('src/layout'))
        .set('@static', resolve('src/static'))
  
      const svgRule = config.module.rule('svg')
      svgRule.uses.clear()
      svgRule
        .oneOf('inline')
        .resourceQuery(/inline/)
        .use('vue-svg-icon-loader')
        .loader('vue-svg-icon-loader')
        .end()
        .end()
        .oneOf('external')
        .use('file-loader')
        .loader('file-loader')
        .options({
          name: 'assets/[name].[hash:8].[ext]'
        })
  
      // 生产环境下关闭css压缩的 colormin 项，因为此项优化与主题色替换功能冲突
      if (isProd) {
        config.plugin('optimize-css')
          .tap(args => {
            args[0].cssnanoOptions.preset[1].colormin = false
            return args
          })
      }
    },
  
    css: {
      loaderOptions: {
        less: {
          lessOptions: {
            modifyVars: modifyVars(),
            javascriptEnabled: true
          }
        }
      }
    },
  
    lintOnSave: undefined,
    // babel-loader no-ignore node_modules/*
    transpileDependencies: [],
    publicPath: '/',
    productionSourceMap: false
  }
  
  