Merge pull request #51 from jingsam/build

Build umd library
This commit is contained in:
Aresn 2016-11-14 09:29:25 +08:00 committed by GitHub
commit 7e554530a1
16 changed files with 10650 additions and 52 deletions

5
.babelrc Normal file
View file

@ -0,0 +1,5 @@
{
"presets": ["es2015"],
"plugins": ["transform-runtime"],
"comments": false
}

View file

@ -3,5 +3,5 @@
*.yml *.yml
build/ build/
node_modules/ node_modules/
local/ test/
gulpfile.js gulpfile.js

View file

@ -47,11 +47,6 @@ module.exports = {
js: 'babel' js: 'babel'
} }
}, },
// 转es5
babel: {
presets: ['es2015'],
plugins: ['transform-runtime']
},
resolve: { resolve: {
// require时省略的扩展名require('module') 不需要module.js // require时省略的扩展名require('module') 不需要module.js
extensions: ['', '.js', '.vue'], extensions: ['', '.js', '.vue'],

View file

@ -0,0 +1,51 @@
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: {
main: './src/index.js'
},
output: {
path: path.resolve(__dirname, '../dist'),
publicPath: '/dist/',
filename: 'iview.js',
library: 'iview',
libraryTarget: 'umd',
umdNamedDefine: true
},
externals: {
'vue': 'Vue'
},
resolve: {
extensions: ['', '.js', '.vue']
},
module: {
loaders: [{
test: /\.vue$/,
loader: 'vue'
}, {
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/
}, {
test: /\.css$/,
loader: 'style!css!autoprefixer'
}, {
test: /\.less$/,
loader: 'style!css!less'
}, {
test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
loader: 'url?limit=8192'
}, {
test: /\.(html|tpl)$/,
loader: 'vue-html'
}]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"development"'
}
})
]
}

View file

@ -0,0 +1,57 @@
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: {
main: './src/index.js'
},
output: {
path: path.resolve(__dirname, '../dist'),
publicPath: '/dist/',
filename: 'iview.min.js',
library: 'iview',
libraryTarget: 'umd',
umdNamedDefine: true
},
externals: {
'vue': 'Vue'
},
resolve: {
extensions: ['', '.js', '.vue']
},
module: {
loaders: [{
test: /\.vue$/,
loader: 'vue'
}, {
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/
}, {
test: /\.css$/,
loader: 'style!css!autoprefixer'
}, {
test: /\.less$/,
loader: 'style!css!less'
}, {
test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
loader: 'url?limit=8192'
}, {
test: /\.(html|tpl)$/,
loader: 'vue-html'
}]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin()
]
}

10478
dist/iview.js vendored Normal file

File diff suppressed because it is too large Load diff

5
dist/iview.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -13,10 +13,13 @@
"ui", "ui",
"framework" "framework"
], ],
"main": "src/index.js", "main": "dist/iview.js",
"scripts": { "scripts": {
"dev": "webpack-dev-server --content-base test/ --open --inline --hot --compress --history-api-fallback --port 8081 --config build/webpack.config.js", "dev": "webpack-dev-server --content-base test/ --open --inline --hot --compress --history-api-fallback --port 8081 --config build/webpack.dev.config.js",
"build": "gulp --gulpfile build/build-style.js" "build": "gulp --gulpfile build/build-style.js",
"dist:dev": "webpack --config build/webpack.dist.dev.config.js",
"dist:prod": "webpack --config build/webpack.dist.prod.config.js",
"dist": "npm run dist:dev && npm run dist:prod"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -31,7 +34,7 @@
"popper.js": "^0.6.4" "popper.js": "^0.6.4"
}, },
"peerDependencies": { "peerDependencies": {
"vue": "^1.0.26" "vue": "^1.0.17"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer-loader": "^2.0.0", "autoprefixer-loader": "^2.0.0",

View file

@ -36,22 +36,23 @@ const iview = {
Badge, Badge,
Breadcrumb, Breadcrumb,
BreadcrumbItem: Breadcrumb.Item, BreadcrumbItem: Breadcrumb.Item,
Button, iButton: Button,
ButtonGroup: Button.Group, ButtonGroup: Button.Group,
Card, Card,
Checkbox, Checkbox,
CheckboxGroup: Checkbox.Group, CheckboxGroup: Checkbox.Group,
Circle, Circle,
Col, iCol: Col,
Collapse, Collapse,
Icon, Icon,
iInput: Input,
InputNumber, InputNumber,
LoadingBar, LoadingBar,
Message, Message,
Modal, Modal,
Notice, Notice,
Option, iOption: Option,
OptionGroup: OptionGroup, OptionGroup,
Page, Page,
Panel: Collapse.Panel, Panel: Collapse.Panel,
Poptip, Poptip,
@ -59,7 +60,7 @@ const iview = {
Radio, Radio,
RadioGroup: Radio.Group, RadioGroup: Radio.Group,
Row, Row,
Select, iSelect: Select,
Slider, Slider,
Spin, Spin,
Step: Steps.Step, Step: Steps.Step,
@ -68,15 +69,18 @@ const iview = {
Tag, Tag,
Timeline, Timeline,
TimelineItem: Timeline.Item, TimelineItem: Timeline.Item,
Tooltip, Tooltip
iButton: Button,
iButtonGroup: Button.Group,
iCol: Col,
iInput: Input,
iOption: Option,
iOptionGroup: OptionGroup,
iSelect: Select
}; };
module.exports = iview; const install = function (Vue) {
Object.keys(iview).forEach((key) => {
Vue.component(key, iview[key])
})
}
// auto install
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue);
};
module.exports = Object.assign(iview, {install});

View file

@ -169,14 +169,14 @@
</Button-group> </Button-group>
</template> </template>
<script> <script>
import { Button, Icon, Input, Switch, Radio, Checkbox, InputNumber, Row, Col, Page } from 'iview'; import { iButton, Icon, Input, Switch, Radio, Checkbox, InputNumber, Row, Col, Page } from 'iview';
const ButtonGroup = Button.Group; const ButtonGroup = iButton.Group;
const RadioGroup = Radio.Group; const RadioGroup = Radio.Group;
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
export default { export default {
components: { components: {
iButton: Button, iButton,
ButtonGroup, ButtonGroup,
Icon, Icon,
iInput: Input, iInput: Input,

View file

@ -21,7 +21,7 @@
export default { export default {
components: { components: {
Message, Message,
Button, iButton,
Alert, Alert,
Card, Card,
Notice, Notice,
@ -121,4 +121,4 @@
// }); // });
} }
} }
</script> </script>

View file

@ -67,10 +67,10 @@
<Step title="待进行" content="这里是该步骤的描述信息"></Step> <Step title="待进行" content="这里是该步骤的描述信息"></Step>
<Step title="待进行" content="这里是该步骤的描述信息"></Step> <Step title="待进行" content="这里是该步骤的描述信息"></Step>
</Steps> </Steps>
<Button @click="testStatus = 'process'">change Status</Button> <i-button @click="testStatus = 'process'">change Status</i-button>
</template> </template>
<script> <script>
import { Badge, Tag, Progress, Circle, Timeline, Icon, Affix, Button, BackTop, Spin, Steps, Breadcrumb} from 'iview'; import { Badge, Tag, Progress, Circle, Timeline, Icon, Affix, iButton, BackTop, Spin, Steps, Breadcrumb} from 'iview';
const TimelineItem = Timeline.Item; const TimelineItem = Timeline.Item;
const Step = Steps.Step; const Step = Steps.Step;
const BreadcrumbItem = Breadcrumb.Item; const BreadcrumbItem = Breadcrumb.Item;
@ -85,7 +85,7 @@
TimelineItem, TimelineItem,
Icon, Icon,
Affix, Affix,
Button, iButton,
BackTop, BackTop,
Spin, Spin,
Steps, Steps,
@ -94,7 +94,7 @@
BreadcrumbItem BreadcrumbItem
}, },
props: { props: {
}, },
data () { data () {
return { return {
@ -108,7 +108,7 @@
} }
}, },
computed: { computed: {
}, },
methods: { methods: {
closed (e) { closed (e) {
@ -130,4 +130,4 @@
}, 1000) }, 1000)
} }
} }
</script> </script>

View file

@ -153,10 +153,10 @@
</div> </div>
</template> </template>
<script> <script>
import { Tooltip, Button, Row, iCol, Poptip, iSelect, iOption, Message, Icon } from 'iview'; import { Tooltip, iButton, Row, iCol, Poptip, iSelect, iOption, Message, Icon } from 'iview';
export default { export default {
components: { Tooltip, iButton: Button, Row, iCol, Poptip, iSelect, iOption, Message, Icon }, components: { Tooltip, iButton, Row, iCol, Poptip, iSelect, iOption, Message, Icon },
props: { props: {
}, },

View file

@ -20,10 +20,10 @@
<Radio value="印度黑羚"></Radio> <Radio value="印度黑羚"></Radio>
</Radio-group> </Radio-group>
<br><br> <br><br>
<Button @click="activeKey = '2'"></Button> <i-button @click="activeKey = '2'"></i-button>
</div> </div>
<Radio :checked.sync="radio">Radio</Radio> <Radio :checked.sync="radio">Radio</Radio>
<Button @click="radio = !radio">change radio</Button> <i-button @click="radio = !radio">change radio</i-button>
<br> <br>
<br> <br>
<Radio-group :model.sync="phone" type="button"> <Radio-group :model.sync="phone" type="button">
@ -145,7 +145,7 @@
<Checkbox :checked.sync="single"></Checkbox> <Checkbox :checked.sync="single"></Checkbox>
</template> </template>
<script> <script>
import { Radio, Alert, Icon, Collapse, Button, Checkbox, Switch, InputNumber, Breadcrumb, LoadingBar } from 'iview'; import { Radio, Alert, Icon, Collapse, iButton, Checkbox, Switch, InputNumber, Breadcrumb, LoadingBar } from 'iview';
const RadioGroup = Radio.Group; const RadioGroup = Radio.Group;
const Panel = Collapse.Panel; const Panel = Collapse.Panel;
@ -160,7 +160,7 @@
Icon, Icon,
Collapse, Collapse,
Panel, Panel,
Button, iButton,
Checkbox, Checkbox,
CheckboxGroup, CheckboxGroup,
Switch, Switch,
@ -203,4 +203,4 @@
LoadingBar.start(); LoadingBar.start();
} }
} }
</script> </script>

View file

@ -27,18 +27,18 @@
<i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option> <i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option>
</i-select> </i-select>
<i-select :model.sync="model7" style="width:200px"> <i-select :model.sync="model7" style="width:200px">
<i-option-group label="热门城市"> <Option-group label="热门城市">
<i-option v-for="item in cityList | limitBy 3" :value="item.value">{{ item.label }}</i-option> <i-option v-for="item in cityList | limitBy 3" :value="item.value">{{ item.label }}</i-option>
</i-option-group> </Option-group>
<i-option-group label="其它城市"> <Option-group label="其它城市">
<i-option v-for="item in cityList | limitBy 3 3" :value="item.value">{{ item.label }}</i-option> <i-option v-for="item in cityList | limitBy 3 3" :value="item.value">{{ item.label }}</i-option>
</i-option-group> </Option-group>
</i-select> </i-select>
</template> </template>
<script> <script>
import { iSelect, iOption, iButton, iOptionGroup } from 'iview'; import { iSelect, iOption, iButton, OptionGroup } from 'iview';
export default { export default {
components: { iSelect, iOption, iButton, iOptionGroup }, components: { iSelect, iOption, iButton, OptionGroup },
data () { data () {
return { return {
cityList: [ cityList: [

View file

@ -58,7 +58,7 @@
</Steps> </Steps>
</template> </template>
<script> <script>
import { Page, Steps, Button } from 'iview'; import { Page, Steps, iButton } from 'iview';
const Step = Steps.Step; const Step = Steps.Step;
@ -67,7 +67,7 @@
Page, Page,
Steps, Steps,
Step, Step,
iButton: Button iButton
}, },
props: { props: {