Переглянути джерело

【看板展示】【减小打包体积-通用代码提取】

zhuth 8 роки тому
батько
коміт
57fcc1d1d7

+ 2 - 9
kanban-client/app/component/converter.js

@@ -1,13 +1,8 @@
 import Renders from '../utils/RenderUtils.js';
 
 function converter(data) {
-    let { title, content } = data;
-    // title = {
-    //     config: {
-    //         render: 'titleRender'
-    //     }
-    // }
-    let { items } = content;
+    let { content } = data;
+    let { title, items } = content;
     let itemsarr = items instanceof Array ? items : [items];
 	
     let me = this;
@@ -69,7 +64,6 @@ function formConfig(model) {
 function tableConfig(model) {
     let { type, config, layout } = model;
     let { fontSize, title, cls, render, columns, data, rowHeight} = config;
-    
     return {
         type: 'table',
         config: {
@@ -393,7 +387,6 @@ function getScreenSize() {
 }
 
 function getFontSize(layout) {
-    const MAX_FONT_SIZE = 25;
     let {screenHeight, screenWidth} = getScreenSize();
     if(screenWidth > 800) {
         return 22;

+ 1 - 0
kanban-client/build/index.html

@@ -8,6 +8,7 @@
 <body style="margin:0px">
   <div id="root"></div>
   <script type="text/javascript" src="./lib/echarts-for-react/echarts.min.js"></script>
+  <script src="./commons.bundle.js"></script>
   <script src="./src/main.bundle.js"></script>
 </body>
 </html>

+ 3 - 6
kanban-client/package.json

@@ -19,22 +19,19 @@
     "component-classes": "^1.2.6",
     "echarts-for-react": "^1.4.4",
     "element-resize-event": "^2.0.9",
-    "g2": "^2.3.8",
-    "g2-mobile": "^2.1.22",
-    "g2-react": "^1.3.0",
     "json-loader": "^0.5.4",
-    "less": "^2.7.2",
-    "less-loader": "^4.0.5",
     "lodash.get": "^4.4.2",
     "prop-types": "^15.5.8",
     "rc-util": "4.x",
     "react-grid-layout": "^0.14.7",
     "shallowequal": "^0.2.2",
     "thenby": "^1.2.3",
-    "warning": "^3.0.0",
     "whatwg-fetch": "^2.0.3"
   },
   "devDependencies": {
+    "warning": "^3.0.0",
+    "less": "^2.7.2",
+    "less-loader": "^4.0.5",
     "babel-core": "^6.25.0",
     "babel-eslint": "^7.2.3",
     "babel-loader": "^7.1.1",

+ 8 - 3
kanban-client/webpack.config.js

@@ -4,7 +4,7 @@ var ExtractTextPlugin = require('extract-text-webpack-plugin');
 
 module.exports = {
     entry: {
-        'fetch/whatwg-fetch': 'whatwg-fetch',
+        'src/whatwg-fetch': 'whatwg-fetch',
         'src/main': './app/main.js',
         'src/title': './app/src/Title/Title.jsx',
         'src/table': './app/component/Table.jsx',
@@ -12,7 +12,7 @@ module.exports = {
         'src/chart': './app/src/Charts/ECharts.js'
     },
     externals: {
-        echarts: 'window.echarts',
+        echarts: 'window.echarts'
     },
     output: {
         path: path.resolve(__dirname, './build'),
@@ -75,6 +75,11 @@ module.exports = {
                 return getPath('css/[name].css').replace('src/', '').replace('css/js', 'css');
             },
             allChunks: true
-        })
+        }),
+        new webpack.optimize.CommonsChunkPlugin({ 
+            names: 'commons',
+            filename: '[name].bundle.js',
+            minChunks: 4,
+        }),
     ]
 };