const path = require('path')
const webpack = require('webpack')
const veuiLoaderOptions = require('./build/veui-loader.conf')
const devServer = require('./build/dev-server')

function resolve (dir) {
  return path.join(__dirname, dir)
}

const VEUI_PREFIX = process.env.VEUI_PREFIX || process.env.VUE_APP_VEUI_PREFIX
const vars = {}

module.exports = {
  lintOnSave: false,
  css: {
    loaderOptions: {
      less: {
        lessOptions: {
          javascriptEnabled: true,
          modifyVars: {
            ...vars,
            ...(VEUI_PREFIX
              ? {
                'veui-prefix': VEUI_PREFIX
              }
              : {})
          }
        }
      }
    }
  },
  publicPath: process.env.BASE_PATH || '/',
  outputDir: '../../components',
  transpileDependencies: [
    /[/\\]node_modules[/\\]veui[/\\]/,
    /[/\\]node_modules[/\\]veui-theme-dls[/\\]/,
    /[/\\]node_modules[/\\]vue-awesome[/\\]/,
    /[/\\]node_modules[/\\]resize-detector[/\\]/
  ],
  chainWebpack: config => {
    config
      .entry('app')
      .clear()
      .add('./demo/main.js')

    config.plugin('html').tap(args => {
      args[0].template = './demo/index.html'
      return args
    })

    if (process.env.NODE_ENV === 'test') {
      config.devtool('cheap-module-eval-source-map')
    }

    config.resolve.alias
      .set(
        'vue$',
        process.env.NODE_ENV === 'test'
          ? 'vue/dist/vue.esm.js'
          : 'vue/dist/vue.runtime.esm.js'
      )
      .set('veui', resolve('src'))
      .set('veui-theme-one-icons', resolve('../veui-theme-one-icons/icons'))
      .set('veui-theme-dls-icons', resolve('../veui-theme-dls-icons/icons'))

    config.module
      .rule('vue')
      .use('vue-loader')
      .tap(options => ({
        ...options,
        compilerOptions: {
          ...options.compilerOptions,
          whitespace: 'condense'
        }
      }))

    config.module
      .rule('vueMain')
      .test(/\.vue$/)
      .sideEffects(false)

    config.module
      .rule('vueStyle')
      .test(/\.vue$/)
      .resourceQuery(/type=style/)
      .sideEffects(true)

    config.module
      .rule('veui')
      .test(/\.vue$/)
      .pre()
      .use('veui-loader')
      .loader('veui-loader')
      .tap(() => veuiLoaderOptions)

    config
      .plugin('context-replacement')
      .use(webpack.ContextReplacementPlugin, [/moment[\\/]locale$/, /^$/])
  },
  devServer
}

@@ -988,22 +988,24 @@
 ebpack: 
+(
 config
+)
  =%3E %7B%0A  
@@ -1012,23 +1012,16 @@
   config
-%0A      
 .entry('
@@ -1029,23 +1029,16 @@
 pp')
-%0A      
 .clear()
 %0A   
@@ -1033,23 +1033,16 @@
 .clear()
-%0A      
 .add('./
@@ -1087,20 +1087,22 @@
 l').tap(
+(
 args
+)
  =%3E %7B%0A  
@@ -1713,23 +1713,25 @@
    .tap(
+(
 options
+)
  =%3E (%7B%0A 
@@ -2248,16 +2248,96 @@
 tions)%0A%0A
+    config.module.rules.delete('scss')%0A%0A    config.module.rules.delete('sass')%0A%0A
     conf

remove sass/scss rules from webpack config