Browse Source

upd:uploader add header
1. uploader组件 支持自定义header功能;
2. 新增 github issue模板;
3. 新增 webpack.dev.conf构建环境多入口模式;
4. 新增 dev环境热更新配置,公共模块;
5. 新增 nutui.d.ts Infiniteloading types类型;
6. dev 构建环境支持 doc文档和mobile 示例 同时调试;

richard1015 6 years ago
parent
commit
3511c394f0
6 changed files with 165 additions and 10 deletions
  1. 34 0
      .github/issue_template.md
  2. 7 5
      build/webpack.base.conf.js
  3. 116 0
      build/webpack.dev.conf.js
  4. 3 2
      package.json
  5. 4 3
      sites/doc/app.vue
  6. 1 0
      types/nutui.d.ts

+ 34 - 0
.github/issue_template.md

@@ -0,0 +1,34 @@
+---
+name: '缺陷问题反馈'
+about: '如何正确的提出一个 Issue'
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+<!--
+感谢您向我们反馈问题,为了高效的解决问题,我们期望你能提供以下信息:
+-->
+
+## What happens?
+<!-- 清晰的描述下遇到的问题。-->
+
+## 最小可复现仓库
+> 请创建最小可复现代码,并上传到你的 GitHub 仓库
+
+<!-- https://github.com/YOUR_REPOSITORY_URL -->
+## 预期的行为和实际行为
+
+
+## 复现步骤,具体代码
+
+
+<!-- 请提供复现步骤,错误日志以及相关配置 -->
+<!-- 可以尝试不要锁版本,重新安装依赖试试先 -->
+
+
+## 相关环境信息
+- **操作系统**:
+- **Node 版本**:
+- **NutUI 版本**:

+ 7 - 5
build/webpack.base.conf.js

@@ -85,7 +85,7 @@ module.exports = {
     plugins: [
     plugins: [
         new webpack.BannerPlugin({
         new webpack.BannerPlugin({
             banner: `NutUI v${config.version} - [filebase], [hash], ${moment().format()}
             banner: `NutUI v${config.version} - [filebase], [hash], ${moment().format()}
-(c) 2017-2018 JDC
+(c) 2017-2019 JDC
 Released under the MIT License.`
 Released under the MIT License.`
         }),
         }),
         new HappyPack({
         new HappyPack({
@@ -105,10 +105,12 @@ Released under the MIT License.`
             format: '  build [:bar] ' + chalk.green.bold(':percent') + ' (:elapsed seconds)',      
             format: '  build [:bar] ' + chalk.green.bold(':percent') + ' (:elapsed seconds)',      
             clear: false, 
             clear: false, 
             width: 100
             width: 100
-          }),
-          new WebpackBuildNotifierPlugin({
-            title: "My Project Webpack Build",        
+        }),
+        new WebpackBuildNotifierPlugin({
+            title: "NutUI Webpack Build",        
             suppressSuccess: true
             suppressSuccess: true
-          })
+        }),
+        new webpack.HotModuleReplacementPlugin(),
+        new webpack.NamedModulesPlugin(),
     ],
     ],
 }
 }

+ 116 - 0
build/webpack.dev.conf.js

@@ -0,0 +1,116 @@
+const config = require('../package.json');
+const path = require('path');
+const webpackBaseConf = require('./webpack.base.conf.js');
+const HtmlWebpackPlugin = require('html-webpack-plugin');
+const MiniCssExtractPlugin = require("mini-css-extract-plugin");
+const merge = require('webpack-merge');
+const mdtohtml = require('../scripts/mdToVue');
+const isDev = process.env.NODE_ENV === 'development';
+
+
+module.exports = merge(webpackBaseConf, {
+    mode: 'development',
+    entry: {
+        'nutui-mobile': './sites/demo/app.js',
+        'nutui-doc': './sites/doc/app.js',
+    },
+    output: {
+        publicPath: '/',
+        filename: '[name].js',
+    },
+    module: {
+        rules: [
+            //自定义主题
+            // {
+            //     test: /\.(sa|sc|c)ss$/,
+            //     use: [
+            //         {
+            //             loader: 'sass-loader',
+            //             options: {
+            //                 data: `@import "./sites/demo/asset/css/custom.scss";@import "./src/styles/index.scss"; `,
+            //             },
+            //         }
+            //     ],
+            // }
+        ]
+    },
+    optimization: {
+        splitChunks: {
+            cacheGroups: {
+                chunks: {
+                    chunks: 'all',
+                    minChunks: 2,
+                    minSize: 0,
+                    name: 'chunks'
+                }
+            }
+        }
+    },
+    plugins: [
+        //demo 
+        new HtmlWebpackPlugin({
+            template: './sites/demo/index.html',
+            filename: 'demo.html',
+            hash: true,//防止缓存
+            inject: true,
+            chunks: ['chunks', 'nutui-mobile'],
+            minify: {
+                multihtmlCache: true,// 解决多页打包的关键!
+                minifyJS: true,
+                minifyCSS: true,
+                removeAttributeQuotes: true//压缩 去掉引号
+            }
+        }),
+        // doc
+        new mdtohtml({
+            entry: './src',
+            output: './sites/doc/view/',
+            template: './doc-site/template.html',
+            nav: 'left',
+            needCode: true,
+            isbuild: isDev,
+            hasMarkList: false
+        }),
+        new mdtohtml({
+            entry: './docs',
+            output: './sites/doc/page/',
+            template: './doc-site/template.html',
+            nav: 'left',
+            needCode: false,
+            isbuild: isDev
+        }),
+        new HtmlWebpackPlugin({
+            template: './sites/doc/index.html',
+            filename: 'default.html',
+            hash: true,//防止缓存
+            inject: true,
+            chunks: ['chunks', 'nutui-doc'],
+            minify: {
+                multihtmlCache: true,// 解决多页打包的关键!
+                minifyJS: true,
+                minifyCSS: true,
+                removeAttributeQuotes: true//压缩 去掉引号
+            }
+        }),
+    ],
+    devtool: 'cheap-module-eval-source-map',
+    devServer: {
+        contentBase: path.resolve(__dirname, 'dist/sites'),
+        compress: true,
+        index: 'default.html',
+        historyApiFallback: true,
+        disableHostCheck: true,
+        host: "0.0.0.0",
+        hot: true,
+        hotOnly: true,
+        inline: true,
+        overlay: {
+            warnings: true,
+            errors: true
+        },
+        watchOptions: {
+            ignored: /node_modules/
+        }
+    }
+
+});

+ 3 - 2
package.json

@@ -12,7 +12,8 @@
     "CHANGELOG.md"
     "CHANGELOG.md"
   ],
   ],
   "scripts": {
   "scripts": {
-    "dev": "npm run dev:demo",
+    "dev": "npm run dev:new",
+    "dev:new": "cross-env NODE_ENV=development DOC_TYPE=true webpack-dev-server -d --open  --config build/webpack.dev.conf.js",
     "dev:carefree": "cross-env NODE_ENV=carefree carefree_env=dev webpack -w --colors --progress --config build/webpack.demo.dev.conf.js",
     "dev:carefree": "cross-env NODE_ENV=carefree carefree_env=dev webpack -w --colors --progress --config build/webpack.demo.dev.conf.js",
     "dev:demo": "cross-env NODE_ENV=development webpack-dev-server -d --open  --config build/webpack.demo.dev.conf.js",
     "dev:demo": "cross-env NODE_ENV=development webpack-dev-server -d --open  --config build/webpack.demo.dev.conf.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",
     "dev:doc": "cross-env NODE_ENV=development DOC_TYPE=true webpack-dev-server -d --open -w --progress --config build/webpack.doc.dev.conf.js",
@@ -160,4 +161,4 @@
     "instrument": false,
     "instrument": false,
     "sourceMap": false
     "sourceMap": false
   }
   }
-}
+}

+ 4 - 3
sites/doc/app.vue

@@ -58,10 +58,10 @@
             <div class="bg">
             <div class="bg">
               <img src="./asset/css/i/phtitle.png" alt>
               <img src="./asset/css/i/phtitle.png" alt>
               <div>
               <div>
-                <input type="text" readonly :value="'https://nutui.jd.com/demo.html#/'+routerName">
+                <input type="text" readonly :value="demourl+routerName">
               </div>
               </div>
             </div>
             </div>
-            <iframe :src="'//nutui.jd.com/demo.html#/'+routerName+'?ver='+version"></iframe>
+            <iframe :src="demourl+routerName+'?ver='+version"></iframe>
           </div>
           </div>
         </div>
         </div>
       </div>
       </div>
@@ -92,7 +92,8 @@ export default {
       showPhone: false,
       showPhone: false,
       searchCurName: "",
       searchCurName: "",
       searchIndex: 0,
       searchIndex: 0,
-      codeurl: ""     
+      codeurl: "",
+      demourl: location.origin + '/demo.html#/'
     };
     };
   },
   },
   watch: {
   watch: {

+ 1 - 0
types/nutui.d.ts

@@ -61,3 +61,4 @@ export declare class CountDown extends UIComponent {}
 export declare class Uploader extends UIComponent {}
 export declare class Uploader extends UIComponent {}
 export declare class TextInput extends UIComponent {}
 export declare class TextInput extends UIComponent {}
 export declare class Avatar extends UIComponent {}
 export declare class Avatar extends UIComponent {}
+export declare class Infiniteloading extends UIComponent {}