const path = require('path');
const fs = require('fs');
const UploadPlugin = require('./upload');
let publicPath;
switch (process.env.NODE_ENV) {
    case 'development':
        publicPath = '/';
        break;
    case 'production':
        publicPath = `https://cdn.raex.vip/www/` + new Date().getTime();
        break;
    case 'test':
        publicPath = `https://cdn.raex.vip/www_test/` + new Date().getTime();
        break;
}
module.exports = {
    publicPath: publicPath,
    devServer: {
        port: 8082,
        disableHostCheck: true
    },
    pluginOptions: {
        'style-resources-loader': {
            preProcessor: 'less',
            patterns: [path.resolve(__dirname, './src/styles/common/', '*.less')]
        }
    },
    chainWebpack: config => {
        if (process.env.NODE_ENV === 'production') {
            config.plugin('upload').use(new UploadPlugin(publicPath.replace('https://cdn.raex.vip/', '')));
        }
        config.output.filename('[name].[hash].js').end();
        config.resolve.alias.set('@assets', path.resolve(__dirname, 'src', 'assets'));
        config.plugin('html').tap(args => {
            args[0].title = process.env.TITLE;
            args[0].app = process.env.VUE_APP_CORDOVA === 'true';
            return args;
        });
    },
    transpileDependencies: ['element-ui', 'swiper', 'ssr-window', 'dom7', 'vue-awesome-swiper', 'vuex'],
    runtimeCompiler: true,
    productionSourceMap: false
};
