const path = require('path')
const poststylus = require('poststylus')
const pxtorem = require('postcss-pxtorem')

const resolve = file => path.resolve(__dirname, file)
const port = process.env.port || process.env.npm_config_port || 9527 // dev port
const name = "应用中心"
module.exports = {
    publicPath: './', // 本地
    outputDir: 'dist',
    assetsDir: 'static',
    lintOnSave: process.env.NODE_ENV === 'development',
    productionSourceMap: false,
    configureWebpack: {
        // provide the app's title in webpack's name field, so that
        // it can be accessed in index.html to inject the correct title.
        name: name,
        resolve: {
            alias: {
                '@': resolve('src')
            }
        }
    },
    devServer: {
        port: port,
        open: true,
        overlay: {
            warnings: false,
            errors: true
        },
        proxy: {
            [process.env.VUE_APP_BASE_API]: {
                target: process.env.VUE_APP_BASE_API,
                changeOrigin: true,
                pathRewrite: {
                    ['^' + process.env.VUE_APP_BASE_API]: ''
                }
            }
        },
        // after: require('./mock/mock-server.js')
    },
    css: {
        loaderOptions: {
            sass: {
                // data: `@import "@/style/index.scss";`
            },
            stylus: {
                use: [
                    poststylus([
                        pxtorem({
                            rootValue: 100,
                            propWhiteList: [],
                            minPixelValue: 2
                        }),
                        'autoprefixer'
                    ])
                ],
                import: [
                    resolve('./src/assets/theme.custom')
                ]
            },
            postcss: {
                plugins: [
                    require('postcss-pxtorem')({
                        rootValue: 100,
                        propWhiteList: [],
                        minPixelValue: 2
                    }),
                    require('autoprefixer')()
                ]
            }
        }
    },
    transpileDependencies: [
        'mand-mobile'
    ]
}
