Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
I
iview-project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
XXL
iview-project
Commits
53b74b99
Commit
53b74b99
authored
Mar 31, 2017
by
梁灏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
publish iview project2
parent
ee2684b2
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
187 additions
and
211 deletions
+187
-211
.babelrc
.babelrc
+5
-0
package.json
package.json
+2
-1
app.vue
src/app.vue
+1
-1
config.js
src/config/config.js
+0
-3
time.js
src/directives/time.js
+0
-17
number-separator.js
src/filters/number-separator.js
+0
-9
logo.png
src/images/logo.png
+0
-0
util.js
src/libs/util.js
+3
-5
main.js
src/main.js
+19
-22
router.js
src/router.js
+8
-9
index.ejs
src/template/index.ejs
+1
-1
vendors.js
src/vendors.js
+3
-0
index.vue
src/views/index.vue
+19
-5
webpack.base.config.js
webpack.base.config.js
+55
-31
webpack.dev.config.js
webpack.dev.config.js
+31
-48
webpack.prod.config.js
webpack.prod.config.js
+40
-59
No files found.
.babelrc
0 → 100644
View file @
53b74b99
{
"presets": [
["es2015", { "modules": false }]
]
}
package.json
View file @
53b74b99
...
...
@@ -4,7 +4,8 @@
"description"
:
"A base project with Vue.js2、Vue-Router、webpack2 and with iView2."
,
"main"
:
"index.js"
,
"scripts"
:
{
"dev"
:
"webpack-dev-server --content-base ./ --inline --hot --compress --history-api-fallback --config webpack.dev.config.js"
,
"init"
:
"webpack --progress --config webpack.dev.config.js"
,
"dev"
:
"webpack-dev-server --content-base ./ --open --inline --hot --compress --history-api-fallback --config webpack.dev.config.js"
,
"build"
:
"webpack --progress --hide-modules --config webpack.prod.config.js"
},
"repository"
:
{
...
...
src/
components/
app.vue
→
src/app.vue
View file @
53b74b99
<
style
scoped
>
@import
'
../
styles/common.css'
;
@import
'styles/common.css'
;
</
style
>
<
template
>
<div>
...
...
src/config/config.js
View file @
53b74b99
/**
* Created by aresn on 16/7/18.
*/
import
Env
from
'./env'
;
let
config
=
{
...
...
src/directives/time.js
deleted
100644 → 0
View file @
ee2684b2
/**
* Created by aresn on 16/7/18.
*/
export
default
{
bind
()
{
},
update
()
{
this
.
el
.
innerHTML
=
new
Date
();
this
.
timeout
=
setInterval
(()
=>
{
this
.
el
.
innerHTML
=
new
Date
();
})
},
unbind
()
{
clearInterval
(
this
.
timeout
);
}
};
\ No newline at end of file
src/filters/number-separator.js
deleted
100644 → 0
View file @
ee2684b2
/**
* Created by aresn on 16/7/4.
*/
/**
* 千位分隔符
* */
export
default
function
(
value
)
{
return
value
.
toString
().
replace
(
/
\B(?=(\d{3})
+$
)
/g
,
','
);
}
\ No newline at end of file
src/images/logo.png
View replaced file @
ee2684b2
View file @
53b74b99
3.8 KB
|
W:
|
H:
1.52 KB
|
W:
|
H:
2-up
Swipe
Onion skin
src/libs/util.js
View file @
53b74b99
/**
* Created by aresn on 16/7/18.
*/
let
util
=
{
};
util
.
alert
=
function
(
content
)
{
window
.
alert
(
content
);
util
.
title
=
function
(
title
)
{
title
=
title
?
title
+
' - Home'
:
'iView project'
;
window
.
document
.
title
=
title
;
};
export
default
util
;
\ No newline at end of file
src/main.js
View file @
53b74b99
/**
* Created by aresn on 16/6/20.
*/
import
Vue
from
'vue'
;
import
iView
from
'iview'
;
import
VueRouter
from
'vue-router'
;
import
App
from
'components/app.vue'
;
import
Routers
from
'./router'
;
import
Env
from
'./config/env
'
;
import
iView
from
'iview
'
;
import
Util
from
'./libs/util
'
;
import
App
from
'./app.vue
'
;
import
'iview/dist/styles/iview.css'
;
Vue
.
use
(
VueRouter
);
Vue
.
use
(
iView
);
// 开启debug模式
Vue
.
config
.
debug
=
true
;
// 路由配置
let
router
=
new
VueRouter
({
// 是否开启History模式的路由,默认开发环境开启,生产环境不开启。如果生产环境的服务端没有进行相关配置,请慎用
history
:
Env
!=
'production'
const
RouterConfig
=
{
mode
:
'history'
,
routes
:
Routers
};
const
router
=
new
VueRouter
(
RouterConfig
);
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
iView
.
LoadingBar
.
start
();
Util
.
title
(
to
.
meta
.
title
);
next
();
});
router
.
map
(
Routers
);
router
.
beforeEach
(()
=>
{
router
.
afterEach
((
to
,
from
,
next
)
=>
{
iView
.
LoadingBar
.
finish
();
window
.
scrollTo
(
0
,
0
);
});
router
.
afterEach
(()
=>
{
});
router
.
redirect
({
'*'
:
"/index"
new
Vue
({
el
:
'#app'
,
router
:
router
,
render
:
h
=>
h
(
App
)
});
router
.
start
(
App
,
'#app'
);
\ No newline at end of file
src/router.js
View file @
53b74b99
/**
* Created by aresn on 16/8/22.
*/
const
routers
=
{
'/index'
:
{
component
(
resolve
)
{
require
([
'./views/index.vue'
],
resolve
);
const
routers
=
[
{
path
:
'/'
,
meta
:
{
title
:
''
},
component
:
(
resolve
)
=>
require
([
'./views/index.vue'
],
resolve
)
}
}
};
];
export
default
routers
;
\ No newline at end of file
src/template/index.ejs
View file @
53b74b99
<!DOCTYPE html>
<html
lang=
"zh-CN"
>
<head>
<title>
Webpack App
</title>
<title>
iView project
</title>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"
>
<link
rel=
"stylesheet"
href=
"<%= htmlWebpackPlugin.files.css[0] %>"
>
...
...
src/vendors.js
0 → 100644
View file @
53b74b99
import
Vue
from
'vue'
;
import
iView
from
'iview'
;
import
VueRouter
from
'vue-router'
;
\ No newline at end of file
src/views/index.vue
View file @
53b74b99
...
...
@@ -14,8 +14,12 @@
}
h2{
color: #666;
margin-bottom: 200px;
p{
margin: 0 0 50px;
}
.ivu-row{
}
.ivu-row-flex{
height: 100%;
}
}
...
...
@@ -23,17 +27,27 @@
<
template
>
<div
class=
"index"
>
<Row
type=
"flex"
justify=
"center"
align=
"middle"
>
<
i-c
ol
span=
"24"
>
<
C
ol
span=
"24"
>
<h1>
<img
src=
"../images/logo.png"
>
</h1>
<h2>
一套基于 Vue.js 的高质量UI组件库
</h2>
</i-col>
<h2>
<p>
Welcome to your iView app!
</p>
<Button
type=
"ghost"
@
click=
"handleStart"
>
Start iView
</Button>
</h2>
</Col>
</Row>
</div>
</
template
>
<
script
>
export
default
{
methods
:
{
handleStart
()
{
this
.
$Modal
.
info
({
title
:
'Bravo'
,
content
:
'Now, enjoy the convenience of iView.'
});
}
}
}
</
script
>
webpack.base.config.js
View file @
53b74b99
/**
* Created by aresn on 16/7/5.
*/
var
path
=
require
(
'path'
);
var
webpack
=
require
(
'webpack'
);
const
path
=
require
(
'path'
);
const
webpack
=
require
(
'webpack'
);
const
ExtractTextPlugin
=
require
(
'extract-text-webpack-plugin'
);
module
.
exports
=
{
// 入口
entry
:
{
main
:
'./src/main'
,
vendors
:
[
'vue'
,
'vue-router'
]
vendors
:
'./src/vendors'
},
// 输出
output
:
{
path
:
path
.
join
(
__dirname
,
'./dist'
)
},
// 加载器
module
:
{
loaders
:
[
{
test
:
/
\.
vue$/
,
loader
:
'vue'
},
{
test
:
/
\.
js$/
,
loader
:
'babel'
,
exclude
:
/node_modules/
},
{
test
:
/
\.
css$/
,
loader
:
'style!css!autoprefixer'
},
{
test
:
/
\.
scss$/
,
loader
:
'style!css!sass?sourceMap'
},
{
test
:
/
\.(
gif|jpg|png|woff|svg|eot|ttf
)\??
.*$/
,
loader
:
'url-loader?limit=8192'
},
{
test
:
/
\.(
html|tpl
)
$/
,
loader
:
'html-loader'
}
]
rules
:
[
{
test
:
/
\.
vue$/
,
loader
:
'vue-loader'
,
options
:
{
loaders
:
{
less
:
ExtractTextPlugin
.
extract
({
use
:
[
'css-loader'
,
'autoprefixer-loader'
,
'less-loader'
],
fallback
:
'vue-style-loader'
}),
css
:
ExtractTextPlugin
.
extract
({
use
:
[
'css-loader'
,
'autoprefixer-loader'
,
'less-loader'
],
fallback
:
'vue-style-loader'
})
}
}
},
{
test
:
/iview
\/
.*
?
js$/
,
loader
:
'babel-loader'
},
{
test
:
/
\.
js$/
,
loader
:
'babel-loader'
,
exclude
:
/node_modules/
},
{
test
:
/
\.
css$/
,
use
:
ExtractTextPlugin
.
extract
({
use
:
[
'css-loader'
,
'autoprefixer-loader'
],
fallback
:
'style-loader'
})
},
{
test
:
/
\.
less/
,
use
:
ExtractTextPlugin
.
extract
({
use
:
[
'autoprefixer-loader'
,
'less-loader'
],
fallback
:
'style-loader'
})
},
// 转es5
babel
:
{
presets
:
[
'es2015'
],
plugins
:
[
'transform-runtime'
]
{
test
:
/
\.(
gif|jpg|png|woff|svg|eot|ttf
)\??
.*$/
,
loader
:
'url-loader?limit=1024'
},
{
test
:
/
\.(
html|tpl
)
$/
,
loader
:
'html-loader'
}
]
},
resolve
:
{
// require时省略的扩展名,如:require('module') 不需要module.js
extensions
:
[
''
,
'.js'
,
'.vue'
],
// 别名,可以直接使用别名来代表设定的路径以及其他
extensions
:
[
'.js'
,
'.vue'
],
alias
:
{
filter
:
path
.
join
(
__dirname
,
'./src/filters'
),
components
:
path
.
join
(
__dirname
,
'./src/components'
)
'vue'
:
'vue/dist/vue.esm.js'
}
}
},
plugins
:
[
]
};
\ No newline at end of file
webpack.dev.config.js
View file @
53b74b99
/**
* Created by aresn on 16/7/5.
*/
const
webpack
=
require
(
'webpack'
);
const
HtmlWebpackPlugin
=
require
(
'html-webpack-plugin'
);
const
ExtractTextPlugin
=
require
(
'extract-text-webpack-plugin'
);
const
merge
=
require
(
'webpack-merge'
);
const
webpackBaseConfig
=
require
(
'./webpack.base.config.js'
);
const
fs
=
require
(
'fs'
);
var
webpack
=
require
(
'webpack'
);
var
config
=
require
(
'./webpack.base.config'
);
var
HtmlWebpackPlugin
=
require
(
'html-webpack-plugin'
);
var
ExtractTextPlugin
=
require
(
'extract-text-webpack-plugin'
);
var
fs
=
require
(
'fs'
);
config
.
devtool
=
'#source-map'
;
// source-map
config
.
output
.
publicPath
=
'/dist/'
;
// 资源路径
config
.
output
.
filename
=
'[name].js'
;
// 入口js命名
config
.
output
.
chunkFilename
=
'[name].chunk.js'
;
// 路由js命名
config
.
vue
=
{
loaders
:
{
css
:
ExtractTextPlugin
.
extract
(
"style-loader"
,
"css-loader?sourceMap"
,
{
publicPath
:
"/dist/"
}
),
less
:
ExtractTextPlugin
.
extract
(
'vue-style-loader'
,
'css-loader!less-loader'
),
sass
:
ExtractTextPlugin
.
extract
(
'vue-style-loader'
,
'css-loader!sass-loader'
)
}
};
fs
.
open
(
'./src/config/env.js'
,
'w'
,
function
(
err
,
fd
)
{
const
buf
=
'export default "development";'
;
fs
.
write
(
fd
,
buf
,
0
,
buf
.
length
,
0
,
function
(
err
,
written
,
buffer
){});
});
config
.
plugins
=
(
config
.
plugins
||
[]).
concat
([
new
ExtractTextPlugin
(
"[name].css"
,{
allChunks
:
true
,
resolve
:
[
'modules'
]
}),
// 提取CSS
new
webpack
.
optimize
.
CommonsChunkPlugin
(
'vendors'
,
'vendors.js'
),
// 提取第三方库
new
HtmlWebpackPlugin
({
// 构建html文件
module
.
exports
=
merge
(
webpackBaseConfig
,
{
devtool
:
'#source-map'
,
output
:
{
publicPath
:
'/dist/'
,
filename
:
'[name].js'
,
chunkFilename
:
'[name].chunk.js'
},
plugins
:
[
new
ExtractTextPlugin
({
filename
:
'[name].css'
,
allChunks
:
true
}),
new
webpack
.
optimize
.
CommonsChunkPlugin
({
name
:
'vendors'
,
filename
:
'vendors.js'
}),
new
HtmlWebpackPlugin
({
filename
:
'../index.html'
,
template
:
'./src/template/index.ejs'
,
inject
:
false
})
]);
// 写入环境变量
fs
.
open
(
'./src/config/env.js'
,
'w'
,
function
(
err
,
fd
)
{
var
buf
=
'export default "development";'
;
fs
.
write
(
fd
,
buf
,
0
,
buf
.
length
,
0
,
function
(
err
,
written
,
buffer
){});
]
});
\ No newline at end of file
module
.
exports
=
config
;
\ No newline at end of file
webpack.prod.config.js
View file @
53b74b99
/**
* Created by aresn on 16/7/5.
*/
const
webpack
=
require
(
'webpack'
);
const
HtmlWebpackPlugin
=
require
(
'html-webpack-plugin'
);
const
ExtractTextPlugin
=
require
(
'extract-text-webpack-plugin'
);
const
merge
=
require
(
'webpack-merge'
);
const
webpackBaseConfig
=
require
(
'./webpack.base.config.js'
);
const
fs
=
require
(
'fs'
);
var
webpack
=
require
(
'webpack'
);
var
config
=
require
(
'./webpack.base.config'
);
var
HtmlWebpackPlugin
=
require
(
'html-webpack-plugin'
);
var
ExtractTextPlugin
=
require
(
'extract-text-webpack-plugin'
);
var
fs
=
require
(
'fs'
);
config
.
output
.
publicPath
=
'./dist/'
;
// 资源路径,根据需要可改为cdn地址
config
.
output
.
filename
=
'[name].[hash].js'
;
// 带hash值的入口js名称
config
.
output
.
chunkFilename
=
'[name].[hash].chunk.js'
;
// 带hash值的路由js名称
config
.
vue
=
{
loaders
:
{
css
:
ExtractTextPlugin
.
extract
(
"style-loader"
,
"css-loader"
,
{
publicPath
:
"../dist/"
// 特别提醒,如果这里的publicPath是以http://xxx.xxx这样以http://开头的,要写成
// publicPath: "http:\\xxx.xxx",否则会编译为"http:/xxx.xxx"
}
),
less
:
ExtractTextPlugin
.
extract
(
'vue-style-loader'
,
'css-loader!less-loader'
),
sass
:
ExtractTextPlugin
.
extract
(
'vue-style-loader'
,
'css-loader!sass-loader'
)
}
};
fs
.
open
(
'./src/config/env.js'
,
'w'
,
function
(
err
,
fd
)
{
const
buf
=
'export default "production";'
;
fs
.
write
(
fd
,
buf
,
0
,
buf
.
length
,
0
,
function
(
err
,
written
,
buffer
){});
});
config
.
plugins
=
(
config
.
plugins
||
[]).
concat
([
new
ExtractTextPlugin
(
"[name].[hash].css"
,{
allChunks
:
true
,
resolve
:
[
'modules'
]
}),
// 提取带hash值的css名称
new
webpack
.
optimize
.
CommonsChunkPlugin
(
'vendors'
,
'vendors.[hash].js'
),
// 提取带hash值的第三方库名称
module
.
exports
=
merge
(
webpackBaseConfig
,
{
output
:
{
publicPath
:
'/dist/'
,
filename
:
'[name].[hash].js'
,
chunkFilename
:
'[name].[hash].chunk.js'
},
plugins
:
[
new
ExtractTextPlugin
({
filename
:
'[name].[hash].css'
,
allChunks
:
true
}),
new
webpack
.
optimize
.
CommonsChunkPlugin
({
name
:
'vendors'
,
filename
:
'vendors.[hash].js'
}),
new
webpack
.
DefinePlugin
({
'process.env'
:
{
NODE_ENV
:
'"production"'
}
}),
new
webpack
.
optimize
.
UglifyJsPlugin
({
// 压缩文件
new
webpack
.
optimize
.
UglifyJsPlugin
({
compress
:
{
warnings
:
false
}
}),
new
HtmlWebpackPlugin
({
// 构建html文件
new
HtmlWebpackPlugin
({
filename
:
'../index_prod.html'
,
template
:
'./src/template/index.ejs'
,
inject
:
false
})
]);
// 写入环境变量
fs
.
open
(
'./src/config/env.js'
,
'w'
,
function
(
err
,
fd
)
{
var
buf
=
'export default "production";'
;
fs
.
write
(
fd
,
buf
,
0
,
buf
.
length
,
0
,
function
(
err
,
written
,
buffer
){});
]
});
\ No newline at end of file
module
.
exports
=
config
;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment