/** @format */
const LoadablePlugin = require('@loadable/webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const AntDesignThemePlugin = require('antd-theme-webpack-plugin')
const path = require('path')
module.exports = {
    plugins: [
        new LoadablePlugin(),
        new CopyPlugin([{
                from: './descrtion/',
                to: 'assets/descrtion',
                toType: 'dir',
            },
            {
                from: './favicon.ico',
                to: '/',
            },
        ]),
        new AntDesignThemePlugin({
            antDir: path.resolve(__dirname, './node_modules/antd'),
            stylesDir: path.resolve(__dirname, './src/styles'),
            varFile: path.resolve(__dirname, './src/styles/variables.less'),
            mainLessFile: path.join(__dirname, './src/styles/global.less'),
            themeVariables: ['@primary-color', '@text-color', '@heading-color'],
            indexFileName: 'index.html',
            generateOnce: false,
            lessUrl: '/assets/descrtion/less.2.7.min.js',
            publicPath: '',
        }),
    ],
    css: [{
            test: /\.less$/i,
            use: [
                'style-loader',
                'css-loader',
                {
                    loader: 'less-loader',
                    options: {
                        // modifyVars: {
                        //     'primary-color': '#12C194',
                        // },
                        javascriptEnabled: true,
                    },
                },
            ],
        },
        {
            test: /\.css$/i,
            use: ['style-loader', 'css-loader'],
        },
    ],
    devServer: {
        host: 'localhost',
        port: 4001,
        proxy: {
            '/api': {
                changeOrigin: true,
                target: 'http://47.108.135.38:41001',
                secure: false,
                pathRewrite:{
                    "":""
                    },
            },
        },
    },
}
