use umi-plugin-dll to enable dll

This commit is contained in:
chencheng
2018-03-26 17:15:27 +08:00
parent 89d22451c5
commit 0fef06e0c6
10 changed files with 21 additions and 95 deletions
+7
View File
@@ -15,5 +15,12 @@ export default {
],
},
],
[
'umi-plugin-dll',
{
exclude: [],
include: ["dva", "dva/router", "dva/saga", "dva/fetch", "antd/es"],
},
],
],
}
+9 -8
View File
@@ -15,24 +15,20 @@
"echarts-liquidfill": "^1.1.0",
"highcharts-exporting": "^0.1.2",
"highcharts-more": "^0.1.2",
"history": "^4.7.2",
"js-beautify": "^1.6.14",
"jsonp": "^0.2.1",
"lodash": "^4.17.4",
"mockjs": "^1.0.1-beta3",
"nprogress": "^0.2.0",
"path-to-regexp": "^2.1.0",
"prop-types": "^15.5.10",
"qs": "^6.5.0",
"rc-tween-one": "^1.3.1",
"react-adsense": "^0.0.5",
"react-countup": "^3.0.2",
"react-draft-wysiwyg": "^1.10.0",
"react-helmet": "^5.1.3",
"react-highcharts": "^15.0.0",
"recharts": "^1.0.0-beta.0",
"umi": "^1.1.0",
"umi-plugin-dva": "^0.4.0",
"umi-plugin-routes": "^0.1.2"
"recharts": "^1.0.0-beta.0"
},
"devDependencies": {
"babel-plugin-dev-expression": "^0.2.1",
@@ -46,7 +42,12 @@
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.7.0",
"less-vars-to-js": "^1.1.2",
"svg-sprite-loader": "^3.7.3"
"mockjs": "^1.0.1-beta3",
"svg-sprite-loader": "^3.7.3",
"umi": "^1.1.2",
"umi-plugin-dll": "^0.1.0",
"umi-plugin-dva": "^0.4.0",
"umi-plugin-routes": "^0.1.2"
},
"pre-commit": [
"lint"
@@ -54,7 +55,7 @@
"scripts": {
"start": "cross-env BABELRC=1 BROWSER=none HOST=0.0.0.0 umi dev",
"lint": "eslint --fix --ext .js src",
"build": "umi build",
"build": "cross-env BABELRC=1 umi build",
"test": "umi test"
}
}
@@ -2,7 +2,7 @@ import React from 'react'
import { Radio } from 'antd'
import { Page } from 'components'
import EchartsComponent from './EchartsComponent'
import styles from './index.less'
import styles from './page.less'
const RadioGroup = Radio.Group
+2 -2
View File
@@ -1,7 +1,7 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
if (typeof define === 'function' && define.amd) { // eslint-disable-line
// AMD. Register as an anonymous module.
define(['exports', 'echarts'], factory)
define(['exports', 'echarts'], factory) // eslint-disable-line
} else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
// CommonJS
factory(exports, require('echarts'))
@@ -2,7 +2,7 @@ import React from 'react'
import { Radio } from 'antd'
import { Page } from 'components'
import ReChartsComponent from './ReChartsComponent'
import styles from './index.less'
import styles from './page.less'
const RadioGroup = Radio.Group
@@ -2,7 +2,7 @@ import React from 'react'
import { Radio } from 'antd'
import { Page } from 'components'
import HighChartsComponent from './HighChartsComponent'
import styles from './index.less'
import styles from './page.less'
const RadioGroup = Radio.Group
-82
View File
@@ -1,82 +0,0 @@
const fs = require('fs')
const path = require('path')
const beautify = require('js-beautify').js_beautify
const config = require('./package.json')
const dist = path.join(`${__dirname}/dist`)
const maxVersion = 5
const writeVersion = () => new Promise((resolve, reject) => {
const { version } = config
const numbers = version.split('.')
numbers[2] = Number(numbers[2]) + 1
config.version = numbers.join('.')
fs.writeFile(path.join(__dirname, 'package.json'), beautify(JSON.stringify(config), { indent_size: 2 }), (err) => {
if (err) {
reject()
}
resolve()
console.log(`version: ${config.version}`)
})
})
const removeFolder = (folderPath) => {
let files = []
if (fs.existsSync(folderPath)) {
files = fs.readdirSync(folderPath)
files.forEach((file) => {
const curPath = `${folderPath}/${file}`
if (fs.statSync(curPath).isDirectory()) {
removeFolder(curPath)
} else {
fs.unlinkSync(curPath)
}
})
fs.rmdirSync(folderPath)
}
}
const start = async () => {
const files = fs.readdirSync(dist)
const promises = files.map(file => new Promise((resolve, reject) => {
fs.stat(`${dist}/${file}`, (err, stats) => {
if (err) {
reject()
} else {
resolve(!stats.isFile()
? file
: null)
}
})
}))
const result = await Promise.all(promises)
const folders = result.filter((item) => {
if (item) {
return item.split('.').length === 3
}
return false
}).sort((a, b) => {
const an = a.split('.').map(_ => Number(_))
const bn = b.split('.').map(_ => Number(_))
if (an[0] === bn[0]) {
if (an[1] === bn[1]) {
return an[2] < bn[2]
}
return an[1] < bn[1]
}
return an[0] < bn[0]
}).filter((item, index) => {
return index > (maxVersion - 1)
})
for (const item of folders) {
await removeFolder(`${dist}/${item}`)
}
await writeVersion()
}
start()