From 73b806e159ff91097365da0aed196a29afd071c1 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 14 Jan 2016 02:37:52 +0800 Subject: [PATCH] upgrade webpack config --- nico.js | 2 +- scripts/demo.js | 1 + scripts/home.js | 203 ++++++++++++++++++++------------------- site/templates/home.html | 1 - webpack.config.js | 2 - webpack.deploy.config.js | 11 ++- 6 files changed, 117 insertions(+), 103 deletions(-) diff --git a/nico.js b/nico.js index 46b7d682ce..4d523e84c4 100644 --- a/nico.js +++ b/nico.js @@ -6,7 +6,7 @@ var inspect = require('util').inspect; var Busboy = require('busboy'); var chalk = require('chalk'); var webpackMiddleware = require('webpack-dev-middleware'); -var webpackConfig = require('./webpack.deploy.config'); +var webpackConfig = require('./webpack.config'); var webpackCompiler = webpack(webpackConfig); var handler; diff --git a/scripts/demo.js b/scripts/demo.js index ac1fe71eda..284d8359f9 100644 --- a/scripts/demo.js +++ b/scripts/demo.js @@ -36,6 +36,7 @@ window.ReactDOM = ReactDOM; window['object-assign'] = require('object-assign'); window['classnames'] = require('classnames'); window['reqwest'] = require('reqwest'); +require('./home')(); antd.DatePicker.locale = { en_US: require('../components/date-picker/locale/en_US'), diff --git a/scripts/home.js b/scripts/home.js index 0ed88c13ff..2b2b8eacc0 100644 --- a/scripts/home.js +++ b/scripts/home.js @@ -4,105 +4,112 @@ import { QueueAnim, Icon, Button } from '../index'; import ScrollOverPack from 'rc-scroll-anim/lib/ScrollOverPack'; import TweenOne from 'rc-tween-one'; -// 导航处理 -function scrollNavEvent() { - const scrollTop = document.body.scrollTop || document.documentElement.scrollTop; - const clientHeight = document.documentElement.clientHeight; - if (scrollTop >= clientHeight) { - header.className = header.className.indexOf('home-nav-bottom') >= 0 ? header.className : header.className + ' home-nav-bottom'; - } else { - header.className = header.className.replace(/home-nav-bottom/ig, ''); - } -} - -$(window).off('scroll.scrollNavEvent'); -$(window).on('scroll.scrollNavEvent', scrollNavEvent); - -class Banner extends React.Component { - constructor() { - super(...arguments); - } - - typeFunc(a) { - if (a.key === 'line') { - return 'right'; - } else if (a.key === 'button') { - return 'bottom'; +module.exports = function() { + InstantClickChangeFns.push(function() { + if (!document.getElementById('banner')) { + return; + } + // 导航处理 + function scrollNavEvent() { + const scrollTop = document.body.scrollTop || document.documentElement.scrollTop; + const clientHeight = document.documentElement.clientHeight; + if (scrollTop >= clientHeight) { + header.className = header.className.indexOf('home-nav-bottom') >= 0 ? header.className : header.className + ' home-nav-bottom'; + } else { + header.className = header.className.replace(/home-nav-bottom/ig, ''); + } } - return 'left'; - } - render() { - return ( -
- -

ANT

DESIGN

-

一个 UI 设计语言

- - 开始探索 + $(window).off('scroll.scrollNavEvent'); + $(window).on('scroll.scrollNavEvent', scrollNavEvent); + + class Banner extends React.Component { + constructor() { + super(...arguments); + } + + typeFunc(a) { + if (a.key === 'line') { + return 'right'; + } else if (a.key === 'button') { + return 'bottom'; + } + return 'left'; + } + + render() { + return ( +
+ +

ANT

DESIGN

+

一个 UI 设计语言

+ + 开始探索 +
+ + + +
+ ) + } + } + + ReactDOM.render(, document.getElementById('banner')); + + // page1 + ReactDOM.render(( + + + +

最佳实践

+

近一年的中后台设计实践,积累了大量的优秀案例。

+
- - - -
- ) - } + + ), document.getElementById('page1')); + + //page2 + ReactDOM.render(( + + +

设计模式

+

总结中后台设计中反复出现的问题,并提供相应的解决方案。

+
+
+
+ +
+ ), document.getElementById('page2')); + + // page3 + ReactDOM.render(( + + + +

丰富的基础组件

+

丰富、灵活、实用的基础组件,为业务产品提供强有力的设计支持。

+
+
+
+ ), document.getElementById('page3')); + + // page4 + ReactDOM.render(( + + +

微小·确定·幸福

+

这是一套致力于提升『用户』和『设计者』使用体验的中后台设计语言。

+
+ +
+ ), document.getElementById('page4')); + }); } - -ReactDOM.render(, document.getElementById('banner')); - -// page1 -ReactDOM.render(( - - - -

最佳实践

-

近一年的中后台设计实践,积累了大量的优秀案例。

-
-
-
-), document.getElementById('page1')); - -//page2 -ReactDOM.render(( - - -

设计模式

-

总结中后台设计中反复出现的问题,并提供相应的解决方案。

-
-
-
- -
-), document.getElementById('page2')); - -// page3 -ReactDOM.render(( - - - -

丰富的基础组件

-

丰富、灵活、实用的基础组件,为业务产品提供强有力的设计支持。

-
-
-
-), document.getElementById('page3')); - -// page4 -ReactDOM.render(( - - -

微小·确定·幸福

-

这是一套致力于提升『用户』和『设计者』使用体验的中后台设计语言。

-
- -
-), document.getElementById('page4')); diff --git a/site/templates/home.html b/site/templates/home.html index 9887659278..56168554e4 100644 --- a/site/templates/home.html +++ b/site/templates/home.html @@ -247,5 +247,4 @@ color: #eee; } - {% endblock %} diff --git a/webpack.config.js b/webpack.config.js index 1e1d2fe777..54d84ea5c9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -4,9 +4,7 @@ var path = require('path'); var pkg = require('./package'); var entry = {}; -entry['index'] = './scripts/importCss.js'; entry['demo'] = './scripts/demo.js'; -entry['home'] = './scripts/home.js'; module.exports = { entry: entry, diff --git a/webpack.deploy.config.js b/webpack.deploy.config.js index 6e830ad998..3cc34f3754 100644 --- a/webpack.deploy.config.js +++ b/webpack.deploy.config.js @@ -1,3 +1,12 @@ +var webpack = require('webpack'); var config = require('./webpack.config'); -delete config.entry.index; + +delete config.devtool; +config.plugins.push(new webpack.optimize.UglifyJsPlugin({ + sourceMap: false, + output: { + ascii_only: true + } +})); + module.exports = config;