diff --git a/build/webpack.dev.config.js b/build/webpack.dev.config.js
index 7d463c1c9..1a32a5496 100644
--- a/build/webpack.dev.config.js
+++ b/build/webpack.dev.config.js
@@ -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')}`],
// 列出第三方库
@@ -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' })
]
}
diff --git a/build/webpack.production.config.js b/build/webpack.production.config.js
index ae14192ad..095f62c4d 100644
--- a/build/webpack.production.config.js
+++ b/build/webpack.production.config.js
@@ -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')}`],
// 列出第三方库
@@ -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)
@@ -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()
]
}
diff --git a/components/upload/Upload.js b/components/upload/Upload.js
index c56ef9833..275b94e59 100644
--- a/components/upload/Upload.js
+++ b/components/upload/Upload.js
@@ -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
@@ -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)
diff --git a/libs/markdown/parse2demo.js b/libs/markdown/parse2demo.js
index 84de0ab63..432d1237c 100644
--- a/libs/markdown/parse2demo.js
+++ b/libs/markdown/parse2demo.js
@@ -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': ['显示代码', '收起代码', '复制代码'],
@@ -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(
+