Skip to content

Commit

Permalink
fix: 完成升级,支撑vue 3.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaofan9 committed Jul 4, 2022
1 parent 2745565 commit d1476d1
Show file tree
Hide file tree
Showing 23 changed files with 39,112 additions and 19,924 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module.exports = {
'eslint:recommended'
],
parserOptions: {
ecmaVersion: 2020
ecmaVersion: 2020,
parser: '@babel/eslint-parser'
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
with:
node-version: '12.x'
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build && npm run build:helper && npx gulp
- run: npm publish --tag next
- run: npm install
- run: npm run build && npx gulp
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
17 changes: 13 additions & 4 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ const { src, dest, series } = require('gulp');
const jsonEditor = require("gulp-json-editor");
const { Reflect } = require('core-js');
const merge = require('merge');
const sass = require('gulp-sass')(require('sass'));
const sassGlob = require('gulp-sass-glob');
const cssnano = require('gulp-cssnano');

const foldPath = './';
const packageFoldPath = './';
const cssFoldPath = './dist';

function package() {
return src("package.json")
Expand All @@ -16,9 +20,14 @@ function package() {
const tmpJson = merge(json, existJson);

Reflect.deleteProperty(tmpJson, 'devDependencies');

return tmpJson;
})).pipe(dest(foldPath));
})).pipe(dest(packageFoldPath));
}

function css() {
return src("./src/style/index.scss").pipe(sassGlob())
.pipe(sass()).pipe(cssnano()).pipe(dest(cssFoldPath));
}

exports.default = series(package)
exports.default = series(css, package)
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,19 @@ yarn add date-week-range@next --save
import DateWeekRange from 'date-week-range'
import { createApp } from 'vue'

// 引入样式;如果全局引入了 element-plus 样式,则不需额外引入
// 引入样式;如果全局引入了 element-plus 样式,则无需再次引入


// 全局引入 element-plus 样式
import 'element-plus/lib/theme-chalk/index.css'
// import 'element-plus/dist/index.css'

// 或引入
// import 'element-plus/theme-chalk/el-icon.css'
// import 'element-plus/theme-chalk/el-date-picker.css'
// import 'element-plus/theme-chalk/el-var.css';

// 或者额外引入
// import 'element-plus/lib/theme-chalk/el-icon.css'
// import 'element-plus/lib/theme-chalk/el-date-picker.css'
// 或引入
// import 'date-week-range/index.css'

const app = createApp({
/* ... */
Expand Down
2 changes: 1 addition & 1 deletion build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const input = path.resolve(foldPath, "src/index.js");
const outputConfig = {
esm: {
format: "esm",
file: path.resolve(foldPath, `dist/${pkg.name}.esm.js`)
file: path.resolve(foldPath, `dist/index.esm.js`)
},
// umd: {
// format: "umd",
Expand Down
82 changes: 45 additions & 37 deletions build/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,70 @@
const path = require('path')
const webpack = require('webpack')
const { VueLoaderPlugin } = require('vue-loader')
const path = require("path");
const webpack = require("webpack");
const { VueLoaderPlugin } = require("vue-loader");
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const pkg = require("../package.json");
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const ProgressBarPlugin = require("progress-bar-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");

let externals = [
{
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
},
},
]
const entry = [path.resolve(__dirname, "..", "src")];
const plugins = [
new VueLoaderPlugin(),
new ProgressBarPlugin(),
// new BundleAnalyzerPlugin(),
new VueLoaderPlugin(),
new webpack.NormalModuleReplacementPlugin(
// eslint-disable-next-line no-useless-escape
/element-plus[/\\]lib[/\\]locale[/\\]lang[/\\]en/,
'zh-cn.js',
),
]
"zh-cn.js"
)
];
const externals = [
{
vue: {
root: "Vue",
commonjs: "vue",
commonjs2: "vue"
}
}
];

const entry = path.resolve(__dirname, '../src/index.js')
const output = {
path: path.resolve(__dirname, "../dist"),
publicPath: "/",
filename: "index.min.js",
libraryTarget: "umd",
library: "DateWeekRange",
umdNamedDefine: true,
globalObject: "typeof self !== 'undefined' ? self : this"
};

const config = {
mode: 'production',
mode: "production",
entry,
output: {
path: path.resolve(__dirname, '../dist'),
publicPath: '/',
filename: pkg.name + '.min.js',
libraryTarget: 'umd',
library: 'DateWeekRange',
umdNamedDefine: true,
globalObject: 'typeof self !== \'undefined\' ? self : this',
},
output,
module: {
rules: [
{
test: /\.vue$/,
use: 'vue-loader',
use: "vue-loader"
},
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
],
loader: "babel-loader"
}
]
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json', '.vue'],
extensions: [".ts", ".tsx", ".js", ".json", ".vue", ".mjs", ".css"]
},
externals,
plugins,
}
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false
})
]
}
};

module.exports = config
module.exports = config;
1 change: 0 additions & 1 deletion dist/date-week-range.esm.js

This file was deleted.

15 changes: 0 additions & 15 deletions dist/date-week-range.min.js

This file was deleted.

1 change: 1 addition & 0 deletions dist/index.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/index.esm.js

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions dist/index.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion example/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>周范围选择器(date-week-range)</title>
<link rel="text/css" href="https://unpkg.com/element-ui/lib/theme-chalk/date-picker.css">
</head>
<body>
<noscript>
Expand Down
7 changes: 0 additions & 7 deletions example/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
:disabled-date="disabledDate"
range-separator=";"
></date-week-range>
<el-date-picker
v-model="test"
type="daterange"
range-separator="666"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</div>
</template>

Expand Down
9 changes: 2 additions & 7 deletions example/src/main.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import { createApp } from 'vue'
import App from './App.vue'
import DateWeekRange from '../../src/index'
import elementPlus from 'element-plus'
import 'element-plus/lib/theme-chalk/el-date-picker.css'
import 'element-plus/lib/theme-chalk/el-icon.css'
import 'dayjs/locale/zh-cn'
import locale from 'element-plus/lib/locale/lang/zh-cn'
import DateWeekRange from '../../dist/index.min'
import '../../dist/index.css'

const app = createApp(App)

app.use(DateWeekRange)
app.use(elementPlus, { locale })
app.mount('#app');

export default app;
Loading

0 comments on commit d1476d1

Please sign in to comment.