This commit is contained in:
2023-05-12 11:35:54 +08:00
parent 97f84ec637
commit 05d1af4837
1521 changed files with 169822 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
const path = require('path')
module.exports = {
env: {
NODE_ENV: '"development"',
},
defineConstants: {
CURRENT_BASE_URL: '"https://test.zzfzyc.com/lymarket"',
CURRENT_CAP_HTML_TO_IMAGE_BASE_URL: '"https://test.zzfzyc.com"',
CURRENT_PAY_H5_CODE_URL: '"https://test.zzfzyc.com/cashier"',
CURRENT_IMG_CND_Prefix: '"https://test.cdn.zzfzyc.com"',
},
mini: {
// optimizeMainPackage: {
// enable: true
// },
webpackChain: (chain, webpack) => {
chain.merge({
plugin: {
install: {
plugin: require('terser-webpack-plugin'),
args: [
{
terserOptions: {
compress: false, // 默认使用terser压缩
// compress: {
// drop_console: true, // 去掉打印
// }, // 默认使用terser压缩
// mangle: false,
keep_classnames: true, // 不改变class名称
keep_fnames: true, // 不改变函数名称
},
},
],
},
},
})
},
},
h5: {},
alias: {
'@': path.resolve(__dirname, '..', 'src'),
},
sass: {
resource: [path.resolve(__dirname, '..', 'src/styles/common.scss'), path.resolve(__dirname, '..', 'src/styles/iconfont.scss')],
},
// plugins: [
// '@tarojs/plugin-react-devtools'
// ],
}
+139
View File
@@ -0,0 +1,139 @@
const path = require('path')
const childProcess = require('child_process')
const versions
= childProcess.execSync('git rev-parse --abbrev-ref HEAD', {
encoding: 'utf8',
}) != 'HEAD\n'
? childProcess.execSync('git rev-parse --abbrev-ref HEAD', {
encoding: 'utf8',
})
: childProcess.execSync('git describe --tags --abbrev=0', {
encoding: 'utf8',
})
const CURRENT_GITHASH = childProcess.execSync('git rev-parse --short HEAD', {
encoding: 'utf8',
})
const CURRENT_VERSION = `Version: ${JSON.stringify(process.env.CODE_BRANCH || versions)} ${CURRENT_GITHASH} ${new Date().toLocaleString()}`.replace(
/\"|\\n/g,
'',
)
const config = {
appid: 'wx64fe67f111d52457', // 测试/体验环境
projectName: 'SpiderSteward',
date: '2022-4-6',
designWidth: 750,
deviceRatio: {
640: 2.34 / 2,
750: 1,
828: 1.81 / 2,
},
sourceRoot: 'src',
outputRoot: 'dist',
defineConstants: {
CURRENT_VERSION: JSON.stringify(CURRENT_VERSION),
CURRENT_GITHASH: JSON.stringify(CURRENT_GITHASH),
CURRENT_ENV: JSON.stringify(process.env.NODE_ENV),
},
copy: {
patterns: [],
options: {},
},
framework: 'react',
mini: {
postcss: {
pxtransform: {
enable: true,
config: {
onePxTransform: false,
},
},
url: {
enable: true,
config: {
limit: 1024, // 设定转换尺寸上限
},
},
cssModules: {
enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]',
},
},
},
enableSourceMap: true, // 默认值:watch 模式下为 true,否则为 false。 用于控制是否生成 js、css 对应的 sourceMap。
},
h5: {
router: {
mode: 'hash',
},
// 设置代理服务器转发
// devServer: {
// proxy: {
// '/mp/': {
// target: Domain,
// pathRewrite: {
// '^/mp/': '' // 所以带有/api/请求的链接一律替换为空并追加域名请求
// },
// changeOrigin: true
// }
// }
// }
// },
output: {
filename: 'js/[name].[hash].js',
chunkFilename: 'js/[name].[chunkhash].js',
},
imageUrlLoaderOption: {
limit: 5000,
name: 'static/images/[name].[hash].[ext]',
},
miniCssExtractPluginOption: {
filename: 'css/[name].[hash].css',
chunkFilename: 'css/[name].[chunkhash].css',
},
devServer: {
https: true,
},
publicPath: '/',
staticDirectory: 'static',
postcss: {
autoprefixer: {
enable: true,
config: {},
},
cssModules: {
enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]',
},
},
},
},
compiler: {
type: 'webpack5',
// 依赖预编译配置
prebundle: {
enable: false,
timings: true,
},
},
// 持久化缓存配置
cache: {
enable: true,
},
plugins: [['@tarojs/plugin-framework-react', { reactMode: 'concurrent' }]],
}
module.exports = function(merge) {
if (process.env.NODE_ENV === 'development') {
return merge({}, config, require('./dev'))
}
if (process.env.NODE_ENV === 'pre') {
return merge({}, config, require('./pre'))
}
return merge({}, config, require('./prod'))
}
+47
View File
@@ -0,0 +1,47 @@
const path = require('path')
module.exports = {
env: {
NODE_ENV: '"pre"',
},
defineConstants: {
CURRENT_BASE_URL: '"https://pre.zzfzyc.com/lymarket"',
CURRENT_CAP_HTML_TO_IMAGE_BASE_URL: '"https://pre.zzfzyc.com"',
CURRENT_PAY_H5_CODE_URL: '"https://pre.zzfzyc.com/cashier"',
CURRENT_IMG_CND_Prefix: '"https://test.cdn.zzfzyc.com"',
},
mini: {
optimizeMainPackage: {
enable: true,
},
webpackChain: (chain, webpack) => {
chain.merge({
plugin: {
install: {
plugin: require('terser-webpack-plugin'),
args: [
{
terserOptions: {
// compress: true, // 默认使用terser压缩
compress: {
drop_console: false, // 去掉打印
}, // 默认使用terser压缩
// mangle: false,
keep_classnames: true, // 不改变class名称
keep_fnames: true, // 不改变函数名称
},
},
],
},
},
})
},
},
h5: {},
alias: {
'@': path.resolve(__dirname, '..', 'src'),
},
sass: {
resource: [path.resolve(__dirname, '..', 'src/styles/common.scss')],
},
}
+56
View File
@@ -0,0 +1,56 @@
const path = require('path')
module.exports = {
env: {
NODE_ENV: '"production"',
},
defineConstants: {
CURRENT_BASE_URL: '"https://www.zzfzyc.com/lymarket"',
CURRENT_CAP_HTML_TO_IMAGE_BASE_URL: '"https://www.zzfzyc.com"',
CURRENT_PAY_H5_CODE_URL: '"https://www.zzfzyc.com/cashier"',
CURRENT_IMG_CND_Prefix: '"https://cdn.zzfzyc.com"',
},
mini: {
optimizeMainPackage: {
enable: false,
},
webpackChain: (chain, webpack) => {
chain.merge({
plugin: {
install: {
plugin: require('terser-webpack-plugin'),
args: [
{
terserOptions: {
// compress: true, // 默认使用terser压缩
compress: {
drop_console: false, // 去掉打印
}, // 默认使用terser压缩
// mangle: false,
keep_classnames: true, // 不改变class名称
keep_fnames: true, // 不改变函数名称
},
},
],
},
},
})
},
},
h5: {
/**
* 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
* 参考代码如下:
* webpackChain (chain) {
* chain.plugin('analyzer')
* .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
* }
*/
},
alias: {
'@': path.resolve(__dirname, '..', 'src'),
},
sass: {
resource: path.resolve(__dirname, '..', 'src/styles/common.scss'),
},
}