Skip to content

Commit

Permalink
Merge pull request #77 from XiaoMi/hotfix/1.3.4
Browse files Browse the repository at this point in the history
Hotfix/1.3.4
  • Loading branch information
sivan authored Jan 28, 2019
2 parents 400e094 + 27697de commit 13b384e
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 57 deletions.
14 changes: 12 additions & 2 deletions build/webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const webpack = require('webpack')
const basePath = path.resolve(__dirname, '../')

module.exports = {
mode: 'development',
entry: {
main: ['babel-polyfill', `${path.resolve(basePath, 'site/main.js')}`],
// 列出第三方库
Expand Down Expand Up @@ -75,8 +76,17 @@ module.exports = {
children: false
},
devtool: 'source-map',
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
name: 'vendor'
}
}
}
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor' })
new webpack.HotModuleReplacementPlugin()
// new webpack.optimize.CommonsChunkPlugin({ name: 'vendor' })
]
}
39 changes: 29 additions & 10 deletions build/webpack.production.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')

const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const basePath = path.resolve(__dirname, '../')

module.exports = {
mode: process.env.NODE_ENV,
entry: {
main: ['babel-polyfill', `${path.resolve(basePath, 'site/main.js')}`],
// 列出第三方库
Expand Down Expand Up @@ -97,6 +98,24 @@ module.exports = {
chunks: false,
children: false
},
optimization: {
minimize: true,
splitChunks: {
cacheGroups: {
vendor: {
name: 'vendor'
},
runtime: {
name: 'runtime'
}
}
},
minimizer: [
new UglifyJsPlugin()
],
usedExports: true,
sideEffects: true
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
Expand All @@ -105,21 +124,21 @@ module.exports = {
root: basePath
}),
new ExtractTextPlugin({
filename: 'styles.[contenthash].css',
filename: 'styles.[hash].css',
allChunks: true
}),
new HtmlWebpackPlugin({
title: 'HIUI Design',
template: path.resolve(__dirname, '../site/index.template.html')
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: ['vendor', 'runtime']
}),
// new webpack.optimize.UglifyJsPlugin({
// compress: {
// warnings: false
// }
// }),
// new webpack.optimize.CommonsChunkPlugin({
// name: ['vendor', 'runtime']
// }),
new webpack.HashedModuleIdsPlugin()
]
}
9 changes: 9 additions & 0 deletions components/upload/Upload.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component } from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'prop-types'
import shallowEqual from 'shallowequal'
import cloneDeep from 'lodash/cloneDeep'

let fileId = 0
Expand Down Expand Up @@ -53,6 +54,14 @@ export default class Upload extends Component {
// overEvent: false
}

componentWillReceiveProps (nextProps) {
if (!shallowEqual(nextProps.defaultFileList, this.props.defaultFileList)) {
this.setState({
fileList: this.prepareDefaultFileList(nextProps.defaultFileList)
})
}
}

prepareDefaultFileList (fileList) {
const _fileList = cloneDeep(fileList)

Expand Down
68 changes: 28 additions & 40 deletions libs/markdown/parse2demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from 'prop-types'
import marked from 'marked'
import { transform } from 'babel-standalone'
import Prism from 'prismjs'
import * as Components from '../../components'

const LANG = {
'zh-CN': ['显示代码', '收起代码', '复制代码'],
Expand Down Expand Up @@ -54,47 +55,34 @@ class Demo extends Component {
}
renderSource (value) {
const { locale, theme } = this.props
import('../../components')
.then(Element => {
const args = ['context', 'React', 'ReactDOM']
const argv = [this, React, ReactDOM]

for (const key in Element) {
args.push(key)
argv.push(Element[key])
}

return { args, argv }
})
.then(({ args, argv }) => {
const code = transform(
`class Demo extends React.Component {
${value}
}
const args = ['context', 'React', 'ReactDOM']
const argv = [this, React, ReactDOM]
const code = transform(
`class Demo extends React.Component {
${value}
}
ReactDOM.render(
<ThemeContext.Provider value='${theme}'>
<LocaleContext.Provider value='${locale}'>
<Demo {...context.props}/>
</LocaleContext.Provider>
</ThemeContext.Provider>
, document.getElementById('${this.playerId}'))
`,
{
presets: ['es2015', 'react']
}
).code

for (const key in Components) {
args.push(key)
argv.push(Components[key])
}
args.push(code)

ReactDOM.render(
<ThemeContext.Provider value='${theme}'>
<LocaleContext.Provider value='${locale}'>
<Demo {...context.props}/>
</LocaleContext.Provider>
</ThemeContext.Provider>
, document.getElementById('${this.playerId}'))
`,
{
presets: ['es2015', 'react']
}
).code

args.push(code)

var Fn = Function
new Fn(...args).apply(null, argv)
})
.catch(err => {
if (process.env.NODE_ENV !== 'production') {
throw err
}
})
var Fn = Function
new Fn(...args).apply(null, argv)
}

render () {
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hi-ui/hiui",
"version": "1.3.1",
"version": "1.3.2",
"description": "HIUI for React",
"scripts": {
"test": "node_modules/.bin/standard && node_modules/.bin/stylelint --config .stylelintrc 'components/**/*.scss'",
Expand Down Expand Up @@ -56,6 +56,7 @@
"redux": "^4.0.0",
"redux-thunk": "^2.3.0",
"shallowequal": "^1.0.2",
"uglifyjs-webpack-plugin": "^2.1.1",
"universal-observer": "^1.0.1",
"warning": "^3.0.0",
"whatwg-fetch": "^2.0.4"
Expand All @@ -77,7 +78,7 @@
"css-loader": "^0.28.11",
"cssnano": "^4.0.5",
"date-fns": "^1.29.0",
"extract-text-webpack-plugin": "^3.0.2",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"file-loader": "^1.1.11",
"gh-pages": "^2.0.1",
"gulp": "^3.9.1",
Expand Down Expand Up @@ -105,8 +106,9 @@
"stylelint-scss": "^3.4.0",
"through2": "^2.0.3",
"url-loader": "^1.0.1",
"webpack": "^3.12.0",
"webpack-dev-server": "^2.11.2"
"webpack": "^4.29.0",
"webpack-cli": "^3.2.1",
"webpack-dev-server": "^3.1.12"
},
"standard": {
"parser": "babel-eslint",
Expand Down
1 change: 0 additions & 1 deletion site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</head>
<body>
<div id="app"></div>
<script type="text/javascript" src="../dist/vendor.js"></script>
<script type="text/javascript" src="../dist/main.js"></script>
</body>
</html>

0 comments on commit 13b384e

Please sign in to comment.