商城测试版v8_1

This commit is contained in:
2022-07-30 17:11:42 +08:00
parent e2b0b0c52b
commit 09e34ecabe
39 changed files with 3360 additions and 3274 deletions
+30 -27
View File
@@ -1,9 +1,14 @@
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 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 = {
projectName: 'EShop',
@@ -12,7 +17,7 @@ const config = {
deviceRatio: {
640: 2.34 / 2,
750: 1,
828: 1.81 / 2
828: 1.81 / 2,
},
sourceRoot: 'src',
outputRoot: 'dist',
@@ -20,37 +25,33 @@ const config = {
defineConstants: {
CURRENT_VERSION: JSON.stringify(CURRENT_VERSION),
CURRENT_GITHASH: JSON.stringify(CURRENT_GITHASH),
CURRENT_ENV: JSON.stringify(process.env.NODE_ENV)
CURRENT_ENV: JSON.stringify(process.env.NODE_ENV),
},
copy: {
patterns: [
],
options: {
}
patterns: [],
options: {},
},
framework: 'react',
mini: {
postcss: {
pxtransform: {
enable: true,
config: {
}
config: {},
},
url: {
enable: true,
config: {
limit: 1024 // 设定转换尺寸上限
}
limit: 1024, // 设定转换尺寸上限
},
},
cssModules: {
enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]'
}
}
}
generateScopedName: '[name]__[local]___[hash:base64:5]',
},
},
},
},
h5: {
publicPath: '/',
@@ -58,23 +59,25 @@ const config = {
postcss: {
autoprefixer: {
enable: true,
config: {
}
config: {},
},
cssModules: {
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]'
}
}
}
}
generateScopedName: '[name]__[local]___[hash:base64:5]',
},
},
},
},
}
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'))
}
+51
View File
@@ -0,0 +1,51 @@
const path = require('path')
module.exports = {
env: {
NODE_ENV: '"pre"',
},
outputRoot: 'pre_dis',
defineConstants: {},
mini: {
optimizeMainPackage: {
enable: true,
},
webpackChain: (chain, webpack) => {
chain.merge({
plugin: {
install: {
plugin: require('terser-webpack-plugin'),
args: [
{
terserOptions: {
// compress: true, // 默认使用terser压缩
compress: {
drop_console: true, // 去掉打印
}, // 默认使用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'),
},
}
+21 -21
View File
@@ -1,35 +1,35 @@
const path = require('path')
module.exports = {
env: {
NODE_ENV: '"production"'
},
defineConstants: {
NODE_ENV: '"production"',
},
defineConstants: {},
mini: {
optimizeMainPackage: {
enable: true
enable: true,
},
webpackChain: (chain, webpack) => {
chain.merge({
plugin: {
install: {
plugin: require('terser-webpack-plugin'),
args: [{
terserOptions: {
// compress: true, // 默认使用terser压缩
compress: {
drop_console: true, // 去掉打印
}, // 默认使用terser压缩
// mangle: false,
keep_classnames: true, // 不改变class名称
keep_fnames: true // 不改变函数名称
}
}]
}
}
args: [
{
terserOptions: {
// compress: true, // 默认使用terser压缩
compress: {
drop_console: true, // 去掉打印
}, // 默认使用terser压缩
// mangle: false,
keep_classnames: true, // 不改变class名称
keep_fnames: true, // 不改变函数名称
},
},
],
},
},
})
}
},
},
h5: {
/**
@@ -45,6 +45,6 @@ module.exports = {
'@': path.resolve(__dirname, '..', 'src'),
},
sass: {
resource: path.resolve(__dirname, '..', 'src/styles/common.scss')
}
resource: path.resolve(__dirname, '..', 'src/styles/common.scss'),
},
}