From b4f0ecafdec797906b67646a3db2bbc124c4fa8d Mon Sep 17 00:00:00 2001 From: fengxiaobo Date: Tue, 20 Aug 2024 09:27:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code Source From: Self Code Description:: Jira: #IAL3TX 市场项目编号(名称): --- build/locale.js | 8 +++++ build/webpack.locale.config.js | 50 ++++++++++++++++++++++++++ package.json | 3 +- src/components/Confirm/Confirm.vue | 6 ++-- src/components/Page/PageRecordScan.vue | 8 +++-- src/components/Page/index.vue | 4 ++- src/components/Select/index.vue | 2 ++ src/components/Table/table.vue | 4 ++- src/index.js | 14 ++++++++ src/locale/index.js | 2 ++ src/locale/lang.js | 8 ++--- src/locale/lang/en-US.js | 5 ++- src/locale/lang/zh-CN.js | 5 ++- 13 files changed, 105 insertions(+), 14 deletions(-) create mode 100644 build/locale.js create mode 100644 build/webpack.locale.config.js diff --git a/build/locale.js b/build/locale.js new file mode 100644 index 0000000..7c81e67 --- /dev/null +++ b/build/locale.js @@ -0,0 +1,8 @@ +const readDir = require('fs').readdirSync; +const files = readDir('./src/locale/lang'); +const entry = {}; +files.forEach(file => { + const name = file.split('.')[0]; + entry[name] = './src/locale/lang/' + file; +}); +module.exports = entry; diff --git a/build/webpack.locale.config.js b/build/webpack.locale.config.js new file mode 100644 index 0000000..89434ff --- /dev/null +++ b/build/webpack.locale.config.js @@ -0,0 +1,50 @@ +const path = require('path'); +const webpack = require('webpack'); +const entry = require('./locale'); +const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); + +process.env.NODE_ENV = 'production'; + +module.exports = { + devtool: 'source-map', + entry, + module: { + rules: [ + { + test: /\.js$/, + loader: 'babel-loader', + options: { + sourceMap: true, + }, + exclude: /node_modules/ + } + ] + }, + output: { + path: path.resolve(__dirname, '../dist/locale'), + publicPath: '/dist/locale/', + filename: '[name].js', + library: 'bview/locale', + libraryTarget: 'umd', + umdNamedDefine: true + }, + externals: { + vue: { + root: 'Vue', + commonjs: 'vue', + commonjs2: 'vue', + amd: 'vue' + } + }, + plugins: [ + new webpack.DefinePlugin({ + 'process.env': { + NODE_ENV: '"production"' + } + }), + new UglifyJsPlugin({ + parallel: true, + sourceMap: true, + }) + ] +}; diff --git a/package.json b/package.json index b7bba85..86e7a7c 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "dist:prod": "webpack --config build/webpack.prod.conf.js", "dist:style": "gulp --gulpfile build/build-styles.js", "dist:dep": "webpack --config build/webpack.prod.dep.conf.js && gulp --gulpfile build/build-copy.js", - "dist": "npm run dist:prod && npm run dist:dep && npm run dist:style", + "dist:locale": "webpack --config build/webpack.locale.config.js", + "dist": "npm run dist:prod && npm run dist:dep && npm run dist:style && npm run dist:locale", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", "changelog:all": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", "lib": "npm run dist && npm run changelog && npm publish --access=public" diff --git a/src/components/Confirm/Confirm.vue b/src/components/Confirm/Confirm.vue index 420bb63..32cad68 100644 --- a/src/components/Confirm/Confirm.vue +++ b/src/components/Confirm/Confirm.vue @@ -70,6 +70,7 @@ See the Mulan PSL v2 for more details.