add umd library build

This commit is contained in:
jingsam 2016-11-03 17:21:04 +08:00
parent 343abe50e7
commit 5e8a2915a1
8 changed files with 20605 additions and 21 deletions

View file

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

View file

@ -0,0 +1,48 @@
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
},
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,54 @@
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
},
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()
]
}

20475
dist/iview.js vendored Normal file

File diff suppressed because it is too large Load diff

12
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,22 @@ 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,
Input, iInput: Input,
InputNumber, InputNumber,
LoadingBar, LoadingBar,
Message, Message,
Modal, Modal,
Notice, Notice,
Option, iOption: Option,
OptionGroup: OptionGroup, OptionGroup: OptionGroup,
Page, Page,
Panel: Collapse.Panel, Panel: Collapse.Panel,
@ -60,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,
@ -69,20 +69,12 @@ 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
}; };
const install = function (Vue) { const install = function (Vue) {
Object.keys(iview).forEach((key) => { Object.keys(iview).forEach((key) => {
Vue.component(key, iview[name]) Vue.component(key, iview[key])
}) })
} }