Files
2026-05-26 11:54:24 +08:00

97 lines
2.0 KiB
TypeScript

import { defineConfig, type UserConfigExport } from '@tarojs/cli'
import path from 'path'
import devConfig from './dev'
import prodConfig from './prod'
export default defineConfig<'vite'>(async merge => {
const themeVariablesPath = path.resolve(__dirname, '..', 'src/theme/variables.scss').replace(/\\/g, '/')
const baseConfig: UserConfigExport<'vite'> = {
projectName: 'app',
date: '2026-5-6',
designWidth: 750,
deviceRatio: {
640: 2.34 / 2,
750: 1,
375: 2,
828: 1.81 / 2
},
sourceRoot: 'src',
outputRoot: 'dist',
alias: {
'@': path.resolve(__dirname, '..', 'src')
},
plugins: [
'@tarojs/plugin-generator'
],
defineConstants: {
},
sass: {
data: `@use "${themeVariablesPath}" as *;\n`
},
copy: {
patterns: [
],
options: {
}
},
framework: 'vue3',
compiler: 'vite',
mini: {
postcss: {
pxtransform: {
enable: true,
config: {
}
},
cssModules: {
enable: false,
config: {
namingPattern: 'module',
generateScopedName: '[name]__[local]___[hash:base64:5]'
}
}
},
},
h5: {
publicPath: '/',
staticDirectory: 'static',
miniCssExtractPluginOption: {
ignoreOrder: true,
filename: 'css/[name].[hash].css',
chunkFilename: 'css/[name].[chunkhash].css'
},
postcss: {
autoprefixer: {
enable: true,
config: {}
},
cssModules: {
enable: false,
config: {
namingPattern: 'module',
generateScopedName: '[name]__[local]___[hash:base64:5]'
}
}
},
},
rn: {
appName: 'taroDemo',
postcss: {
cssModules: {
enable: false
}
}
}
}
if (process.env.NODE_ENV === 'development') {
return merge({}, baseConfig, devConfig)
}
return merge({}, baseConfig, prodConfig)
})