Skip to content

Commit

Permalink
Merge branch 'v2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Franslee committed Apr 15, 2019
2 parents d8d41b6 + 9aaed10 commit 3c9e7a5
Show file tree
Hide file tree
Showing 42 changed files with 1,171 additions and 203 deletions.
23 changes: 0 additions & 23 deletions .babelrc

This file was deleted.

33 changes: 33 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const presets = [
[
"@babel/preset-env",
{
"modules": false,
"targets": {
"browsers": [
"Android >= 4",
"iOS >= 8"
]
},
"useBuiltIns": "usage"
}

]
];

const plugins = [
"@babel/plugin-transform-runtime",
"@babel/plugin-syntax-dynamic-import",
"istanbul"
];


// if (process.env["NODE_ENV"] === "test") {
// presets[0][1].modules = "commonjs";
// }

if (process.env["DOC_TYPE"] === "true") {
presets[0][1].modules = "commonjs";
}

module.exports = { presets, plugins };
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## 2.1.0

`2019-4-15`

* :sparkles: feat: 新增上传组件`Uploader`
* :sparkles: feat: 服务端渲染新增支持按需加载
* :sparkles: chore: UMD包支持commonjs规范,服务端渲染不再需要引commonjs版的构建包了
* :sparkles: chore: 大幅削减完整版构建包体积
* :sparkles: chore: 自动创建新组件配置和模板功能优化
* :sparkles: test: 单元测试功能优化
* :sparkles: upd: `Scroller`组件优化
* :sparkles: upd: `Picker`组件优化
* :bug: fix: 修复`Dialog`组件取消按钮触发事件错误的问题
* :zap: doc: 文档内容修改完善

## 2.0.9

`2019-3-29`
Expand Down
3 changes: 2 additions & 1 deletion README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
## 示例

![NutUI Demo](https://img14.360buyimg.com/uba/jfs/t1/32118/11/559/2782/5c3d81ecEbda0c0f1/5f2b637d11817204.png)
![NutUI Demo](https://img14.360buyimg.com/uba/s260x260_jfs/t1/32118/11/559/2782/5c3d81ecEbda0c0f1/5f2b637d11817204.png)

## 安装使用

Expand All @@ -51,6 +51,7 @@ https://nutui.jd.com
## 链接
* [意见反馈](https://github.com/jdf2e/nutui/issues)
* [更新日志](https://github.com/jdf2e/nutui/releases)
* [案例征集](https://github.com/jdf2e/nutui/issues/16)
* [按需加载插件](https://www.npmjs.com/package/@nutui/babel-plugin-separate-import)
* [模板工程命令行工具(Gaea-cli)](https://github.com/jdf2e/Gaea4)
* 联系我们:nutui@jd.com
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Documents:[2.X](https://nutui.jd.com/default.html#/start) | [1.X](https://nutu
## Links
* [Feedback](https://github.com/jdf2e/nutui/issues)
* [Change Logs](https://github.com/jdf2e/nutui/releases)
* [Case collection](https://github.com/jdf2e/nutui/issues/16)
* [On-demand plugins](https://www.npmjs.com/package/@nutui/babel-plugin-separate-import)
* [Template project command line tool(Gaea-cli)](https://github.com/jdf2e/Gaea4)
* Contact us:nutui@jd.com
Expand Down
14 changes: 4 additions & 10 deletions build/webpack.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,7 @@ module.exports = {
},
module: {
rules: [
test ? {
test: /\.(js|ts)/,
include: path.resolve('src'), // instrument only testing sources with Istanbul, after ts-loader runs
loader: 'istanbul-instrumenter-loader'
}: {},
test ? { test: /\.css$/, use: [{loader: 'style!css'}] } : {},
test ? { test: /\.scss$/, loader: 'style-loader!css-loader!sass-loader' } : {},
test ? { test: /\.scss$/, use: [{loader: 'sass-loader', options:{data: `@import "./src/styles/index.scss"; `,} }]} : {},
!test ?{
!test ? {
test: /\.(sa|sc|c)ss$/,
use: [
isDev ? 'style-loader' : MiniCssExtractPlugin.loader,
Expand Down Expand Up @@ -86,7 +78,9 @@ module.exports = {
},
plugins: [
new webpack.BannerPlugin({
banner: "NutUI2(" + config.version + ") - [filebase], [hash], " + moment().format()
banner: `NutUI v${config.version} - [filebase], [hash], ${moment().format()}
(c) 2017-2018 JDC
Released under the MIT License.`
}),
new VueLoaderPlugin()
],
Expand Down
2 changes: 1 addition & 1 deletion build/webpack.demo.dev.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = merge(baseConf, {
devServer: {
contentBase: path.resolve(__dirname, 'dist/sites/'),
index: 'demo.html',
compress: true, //gzip压缩
compress: true,
historyApiFallback: true,
disableHostCheck: true
}
Expand Down
1 change: 1 addition & 0 deletions build/webpack.prod.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = merge(webpackBaseConf, {
filename: 'nutui.js',
library: 'nutui',
libraryTarget: 'umd',
globalObject: 'this',
umdNamedDefine: true
},
plugins: [
Expand Down
7 changes: 5 additions & 2 deletions build/webpack.prod.disperse.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ module.exports = merge(webpackBaseConf, {
filename: '[name]/[name].js',
library: '[name]',
libraryTarget: 'umd',
globalObject: 'this',
umdNamedDefine: true
},
externals: {
Expand All @@ -68,14 +69,16 @@ module.exports = merge(webpackBaseConf, {
filename: '[name]/[name].css'
}),
new CopyWebpackPlugin([
{ from: path.join(__dirname, "../src/"), to: path.join(__dirname, "../dist/"), ignore: ['demo.vue','doc.md','config.json','nutui.js'] }
{
from: path.join(__dirname, "../src/"), to: path.join(__dirname, "../dist/"), ignore: ['demo.vue', 'doc.md', 'config.json', 'nutui.js', '*.spec.js'] }
]),
new CopyWebpackPlugin([
{ from: path.join(__dirname, "../types/"), to: path.join(__dirname, "../dist/types/")}
]),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
NODE_ENV: '"production"',
PROD_TYPE: '"disp"'
}
})
],
Expand Down
1 change: 1 addition & 0 deletions build/webpack.prod.mini.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = merge(webpackBaseConf, {
filename: 'nutui.min.js',
library: 'nutui',
libraryTarget: 'umd',
globalObject: 'this',
umdNamedDefine: true
},
plugins: [
Expand Down
43 changes: 29 additions & 14 deletions build/webpack.test.conf.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@


const path = require('path');
const baseConf = require('./webpack.demo.base.conf.js');
const prodConf = require('./webpack.prod.conf.js');
const merge = require('webpack-merge');


module.exports = merge(baseConf, {
mode: 'development',
output: {
publicPath: '/',
},

devServer: {
contentBase: path.resolve(__dirname, 'dist'),
compress: true,
historyApiFallback: true,
module.exports = merge(prodConf, {
module: {
rules: [
{
test: /\.(js|ts)/,
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
}
},
{
test: /\.css$/,
use: [{ loader: 'style!css' }]
},
{
test: /\.scss$/,
loader: 'style-loader!css-loader!sass-loader'
},
{
test: /\.scss$/,
use: [{
loader: 'sass-loader',
options: { data: `@import "./src/styles/index.scss"; `, }
}]
},
],
},
externals: [require('webpack-node-externals')()]
devtool: 'inline-cheap-module-source-map',
externals: [require('webpack-node-externals')()]
});
3 changes: 1 addition & 2 deletions docs/international.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ import enUS from '@nutui/nutui/dist/locales/lang/en-US';
locale('en-US', enUS);
```

> 请注意:通过该插件进行按需引用组件时默认引用的是构建后的文件,此时并不支持国际化的功能。如需使用组件库的国际化功能,需要在 **.babelrc** 文件中将 **@nutui/babel-plugin-seperate-import** 插件的 **sourceCode** 参数值设为 **true** 。这样插件将引用未经构建的源文件,同时引用的组件也不再具有 `install` 方法,请使用 `Vue.component` 对组件进行注册。
> 请注意:通过该插件进行按需引用组件时默认引用的是构建后的文件,此时并不支持国际化的功能。如需使用组件库的国际化功能,需要在 babel 的配置文件(如.babelrc)中将 **@nutui/babel-plugin-seperate-import** 插件的 **sourceCode** 参数值设为 **true** 。这样插件将引用未经构建的源文件,同时引用的组件也不再具有 `install` 方法,请使用 `Vue.component` 对组件进行注册。
```bash
//.babelrc
{
"plugins": [
["@nutui/babel-plugin-separate-import", {
Expand Down
4 changes: 2 additions & 2 deletions docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ NutUI是一套京东风格的移动端Vue组件库,开发和服务于移动Web

* UMD版 **nutui.js**
* UMD压缩版 **nutui.min.js**
* CommonJS版 **nutui.common.js**

> AMD 环境、Webpack 等构建工具环境建议使用 UMD 版,非模块化环境(如通过 `<script>` 标签直接引用)建议使用 UMD 压缩版,服务端渲染请使用 CommonJS 版本
> AMD 环境、Webpack 等构建工具环境、服务端建议使用 UMD 版,非模块化环境(如通过 `<script>` 标签直接引用)建议使用 UMD 压缩版。
最新稳定版:![npm](https://img.shields.io/npm/v/@nutui/nutui.svg)

Expand All @@ -53,6 +52,7 @@ NutUI是一套京东风格的移动端Vue组件库,开发和服务于移动Web
* [Webpack](http://webpack.github.io/)
* [意见反馈](https://github.com/jdf2e/nutui/issues)
* [更新日志](https://github.com/jdf2e/nutui/releases)
* [案例征集](https://github.com/jdf2e/nutui/issues/16)
* [模板工程命令行工具(Gaea CLI)](https://www.npmjs.com/package/gaea-cli)
* 联系我们:nutui@jd.com

Expand Down
11 changes: 2 additions & 9 deletions docs/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ CDN 引入示例
</html>
```

> 在页面中直接引入,将无法使用 **主题换肤** 等功能。我们推荐使用 *NPM**YARN* 方式安装,不推荐在页面中直接引入的用法
> 在页面中直接引入,将无法使用 **主题定制** 等功能。我们推荐使用 *NPM**YARN* 方式安装,不推荐在页面中直接引入的用法
* 通过 **Vue CLI** 图形化界面安装

Expand All @@ -93,13 +93,6 @@ NutUI.install(Vue);

> 注意:这种方式将会导入所有组件
> 服务端渲染请引入NutUI的 **commonjs** 版本 **nutui.common.js**
```javascript
//服务端渲染使用NutUI的commonjs版本
import NutUI from '@nutui/nutui/dist/nutui.common.js';
```

## 按需加载

以下两种方式都可以实现只加载用到的组件,从而减少加载的文件体积。
Expand All @@ -112,7 +105,7 @@ import NutUI from '@nutui/nutui/dist/nutui.common.js';
npm i @nutui/babel-plugin-separate-import -D
```

然后配置一下 **.babelrc** 文件
然后配置一下babel的配置文件

```bash
{
Expand Down
2 changes: 1 addition & 1 deletion docs/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import Button from '@nutui/nutui/dist/packages/button/button.js';
import '@nutui/nutui/dist/packages/button/button.scss';
```

3.使用了插件 **[@nutui/babel-plugin-seperate-import](https://www.npmjs.com/package/@nutui/babel-plugin-separate-import)** 进行按需引用时,需修改 **.babelrc** 文件,将 **style** 的设置为 **scss**。该插件将会自动引入指定组件对应的 SCSS 文件。
3.使用了插件 **[@nutui/babel-plugin-seperate-import](https://www.npmjs.com/package/@nutui/babel-plugin-separate-import)** 进行按需引用时,需修改babel的配置文件(如.babelrc,将 **style** 的设置为 **scss**。该插件将会自动引入指定组件对应的 SCSS 文件。

```bash
{
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nutui/nutui",
"version": "2.0.9",
"version": "2.1.0",
"description": "一套轻量级移动端Vue组件库",
"typings": "dist/types/index.d.ts",
"main": "dist/nutui.js",
Expand All @@ -14,15 +14,15 @@
"scripts": {
"dev:demo": "cross-env NODE_ENV=development webpack-dev-server -d --open --progress --config build/webpack.demo.dev.conf.js",
"build:demo": "cross-env NODE_ENV=production webpack --hide-modules --progress --config build/webpack.demo.build.conf.js",
"dev:doc": "cross-env NODE_ENV=development webpack-dev-server -d --open -w --progress --config build/webpack.doc.dev.conf.js",
"doc:clear": "node scripts/clearcache.js",
"dev:doc": "cross-env NODE_ENV=development DOC_TYPE=true webpack-dev-server -d --open -w --progress --config build/webpack.doc.dev.conf.js",
"doc:clear": "node scripts/clearCache.js",
"dev": "npm run dev:demo",
"dev:carefree": "cross-env NODE_ENV=carefree carefree_env=dev webpack -w --colors --progress --config build/webpack.demo.dev.conf.js",
"build:doc": "cross-env NODE_ENV=production webpack --hide-modules --progress --config build/webpack.doc.build.conf.js",
"build:doc": "cross-env NODE_ENV=production DOC_TYPE=true webpack --hide-modules --progress --config build/webpack.doc.build.conf.js",
"build:site": "npm run build:demo && npm run build:doc",
"build:prod": "cross-env NODE_ENV=production webpack --hide-modules --progress --config build/webpack.prod.conf.js && node scripts/createIndexScss.js",
"build:prodmin": "cross-env NODE_ENV=production webpack --hide-modules --progress --config build/webpack.prod.mini.conf.js",
"build:disp": "cross-env NODE_ENV=production webpack --hide-modules --progress --config build/webpack.prod.disperse.conf.js",
"build:disp": "cross-env NODE_ENV=production PROD_TYPE=disp webpack --hide-modules --progress --config build/webpack.prod.disperse.conf.js",
"build:cmn": "cross-env NODE_ENV=production webpack --hide-modules --progress --config build/webpack.prod.cmn.conf.js",
"build": "npm run build:prod && npm run build:prodmin && npm run build:cmn && npm run build:disp",
"eslint": "eslint src/packages/**/*.{js,vue}",
Expand Down
Loading

0 comments on commit 3c9e7a5

Please sign in to comment.