├── .babelrc
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .postcssrc.js
├── README.md
├── build
├── build.js
├── check-versions.js
├── dev-client.js
├── dev-server.js
├── utils.js
├── vue-loader.conf.js
├── webpack.base.conf.js
├── webpack.dev.conf.js
├── webpack.prod.conf.js
└── webpack.test.conf.js
├── config
├── dev.env.js
├── index.js
├── prod.env.js
└── test.env.js
├── dist
├── index.html
└── static
│ ├── css
│ ├── app.dc25af568844368721b7447ec2a8041c.css
│ └── app.dc25af568844368721b7447ec2a8041c.css.map
│ ├── fonts
│ ├── iconfont.42ef16c.eot
│ ├── iconfont.4cf6b7c.woff
│ ├── iconfont.b5270aa.ttf
│ ├── ionicons.05acfdb.woff
│ ├── ionicons.24712f6.ttf
│ └── ionicons.2c2ae06.eot
│ ├── img
│ ├── bg_login.7285dd8.jpg
│ ├── fullstack.e51bafb.jpg
│ ├── fullstack.jpg
│ ├── iconfont.ae14f3b.svg
│ ├── ionicons.621bd38.svg
│ └── logo.png
│ └── js
│ ├── 0.5e3e713f6a7c36f289bb.js
│ ├── 0.5e3e713f6a7c36f289bb.js.map
│ ├── 1.5a794239c1dec6d30537.js
│ ├── 1.5a794239c1dec6d30537.js.map
│ ├── 10.59c75d208fbdc827e31d.js
│ ├── 10.59c75d208fbdc827e31d.js.map
│ ├── 2.53d43735f0056ff82cb8.js
│ ├── 2.53d43735f0056ff82cb8.js.map
│ ├── 3.ac8ef93fe5111e371d5a.js
│ ├── 3.ac8ef93fe5111e371d5a.js.map
│ ├── 4.80576ee168dd2dd7685d.js
│ ├── 4.80576ee168dd2dd7685d.js.map
│ ├── 5.e1285d2811d2c1d8df51.js
│ ├── 5.e1285d2811d2c1d8df51.js.map
│ ├── 6.46bb82873bb8d80806a6.js
│ ├── 6.46bb82873bb8d80806a6.js.map
│ ├── 7.767d02cf34304e62347c.js
│ ├── 7.767d02cf34304e62347c.js.map
│ ├── 8.a8f1ceef290085f8065b.js
│ ├── 8.a8f1ceef290085f8065b.js.map
│ ├── 9.dab85558fe3c5df02348.js
│ ├── 9.dab85558fe3c5df02348.js.map
│ ├── app.cbe980894eec1103c2b7.js
│ ├── app.cbe980894eec1103c2b7.js.map
│ ├── manifest.9015f7858af4fe545ce6.js
│ └── manifest.9015f7858af4fe545ce6.js.map
├── img
├── 1.png
├── 17.png
├── 2.png
├── 74.png
├── add.png
├── chart.png
├── edit.png
├── full.png
├── index.png
├── ip5.png
├── ip5_1.png
├── list.png
├── list2.png
├── login.png
├── 图标.png
├── 图表.png
├── 导航.png
├── 换肤.png
├── 搜索.png
├── 新增.png
├── 注册.png
├── 登录.png
├── 编辑.png
├── 表格.png
└── 首页.png
├── index.html
├── package-lock.json
├── package.json
├── process.yml
├── prod.server.js
├── src
├── App.vue
├── api
│ ├── api.js
│ ├── config.js
│ ├── fetch.js
│ └── index.js
├── assets
│ ├── iconfont
│ │ ├── demo.css
│ │ ├── icon.js
│ │ ├── iconfont.css
│ │ ├── iconfont.eot
│ │ ├── iconfont.js
│ │ ├── iconfont.svg
│ │ ├── iconfont.ttf
│ │ └── iconfont.woff
│ ├── img
│ │ ├── bg_login.jpg
│ │ ├── fullstack.jpg
│ │ └── logo.png
│ ├── js
│ │ └── app.js
│ └── styles
│ │ ├── base
│ │ └── base.less
│ │ ├── cover
│ │ └── cover.less
│ │ ├── layout
│ │ └── layout.less
│ │ └── variable
│ │ └── variable.less
├── common
│ ├── filter
│ │ └── index.js
│ └── utils
│ │ └── index.js
├── components
│ ├── Hello.vue
│ ├── layout
│ │ ├── Home.vue
│ │ ├── aside
│ │ │ └── aside.vue
│ │ ├── base
│ │ │ ├── Box.vue
│ │ │ └── lock.vue
│ │ ├── container
│ │ │ └── Container.vue
│ │ ├── header
│ │ │ └── THeader.vue
│ │ └── navbar
│ │ │ └── NavBar.vue
│ ├── pages
│ │ ├── E404.vue
│ │ ├── E500.vue
│ │ ├── Filter.vue
│ │ ├── Icon.vue
│ │ ├── Login.vue
│ │ ├── NotFound.vue
│ │ ├── SetMenu.vue
│ │ ├── SetMenu2.vue
│ │ └── register.vue
│ └── views
│ │ ├── Article.vue
│ │ ├── Chart.vue
│ │ ├── Index.vue
│ │ ├── List.vue
│ │ ├── Table.vue
│ │ ├── UserInfo.vue
│ │ └── UserList.vue
├── i18n
│ └── zh-CN.js
├── main.js
├── router
│ ├── index.js
│ ├── menu.js
│ └── routes.js
└── store
│ ├── index.js
│ └── modules
│ └── app.js
├── static
├── .gitkeep
└── img
│ ├── fullstack.jpg
│ └── logo.png
└── test
├── e2e
├── custom-assertions
│ └── elementCount.js
├── nightwatch.conf.js
├── runner.js
└── specs
│ └── test.js
└── unit
├── .eslintrc
├── index.js
├── karma.conf.js
└── specs
└── Hello.spec.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["env", {
4 | "modules": false,
5 | "targets": {
6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
7 | }
8 | }],
9 | "stage-2"
10 | ],
11 | "plugins": ["transform-runtime"],
12 | "env": {
13 | "test": {
14 | "presets": ["env", "stage-2"],
15 | "plugins": ["istanbul"]
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | build/*.js
2 | config/*.js
3 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // http://eslint.org/docs/user-guide/configuring
2 |
3 | module.exports = {
4 | root: true,
5 | parser: 'babel-eslint',
6 | parserOptions: {
7 | sourceType: 'module'
8 | },
9 | env: {
10 | browser: true,
11 | },
12 | // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
13 | extends: 'standard',
14 | // required to lint *.vue files
15 | plugins: [
16 | 'html'
17 | ],
18 | // add your custom rules here
19 | // 'rules': {
20 | // // allow paren-less arrow functions
21 | // 'arrow-parens': 0,
22 | // // allow async-await
23 | // 'generator-star-spacing': 0,
24 | // // allow debugger during development
25 | // 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
26 | // "space-before-function-paren": ["error", {
27 | // "anonymous": "always",
28 | // "named": "never", //具名函数后不用空格
29 | // "asyncArrow": "always"
30 | // }],
31 | // "padded-blocks": ["error", {"blocks": "never"}]
32 | // }
33 | }
34 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | npm-debug.log*
4 | yarn-debug.log*
5 | yarn-error.log*
6 | test/unit/coverage
7 | test/e2e/reports
8 | selenium-debug.log
9 |
10 | # Editor directories and files
11 | .idea
12 | *.suo
13 | *.ntvs*
14 | *.njsproj
15 | *.sln
16 |
--------------------------------------------------------------------------------
/.postcssrc.js:
--------------------------------------------------------------------------------
1 | // https://github.com/michael-ciniawsky/postcss-load-config
2 |
3 | module.exports = {
4 | "plugins": {
5 | // to edit target browsers: use "browserlist" field in package.json
6 | "autoprefixer": {}
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-admin
2 |
3 | > vue-admin by iview
4 | ^_^
5 | # demo
6 | ant-design版本 https://github.com/artiely/vue-admin (推荐)
7 |
8 | element版 https://github.com/artiely/element-admin
9 |
10 | ## 项目截图
11 | ### 登录
12 | 
13 | ### 注册
14 | 
15 | ### 首页
16 | 
17 | ### 主题切换
18 | 
19 | ### 搜索
20 | 
21 | ### 编辑
22 | 
23 | ### 图表
24 | 
25 | ### 字体图标
26 | 
27 | ### 响应式
28 |
29 |
30 |
31 | ## 技术栈
32 | > vue
33 |
34 | > vue-cli
35 |
36 | > vuex
37 |
38 | > vue-router
39 |
40 | > axios
41 |
42 | > i18n
43 |
44 | > es6/7
45 |
46 | > webpack2/3
47 |
48 | > less
49 |
50 | > ...
51 |
52 | ## 项目结构
53 |
54 | 这里推荐一个输出项目结构的node模块 `treeplus` https://github.com/artiely/treeplus
55 | ```bash
56 | ├─build // 打包环境
57 | │
58 | ├─config // 开发部署配置
59 | │
60 | ├─node_modules
61 | │
62 | ├─src // 项目源文件
63 | │ │ main.js // 入口文件
64 | │ ├─api // 请求接口
65 | │ │
66 | │ ├─assets // 组件静态资源
67 | │ │ └─styles // 样式
68 | │ │ ├─base // 基础样式
69 | │ │ ├─cover // iview覆盖样式
70 | │ │ ├─layout // 布局样式
71 | │ │ └─variable // 样式变量
72 | │ │
73 | │ ├─common // 公共
74 | │ │ ├─directive
75 | │ │ └─utils
76 | │ │
77 | │ ├─i18n // 国际化
78 | │ ├─components
79 | │ │ │
80 | │ │ ├─layout // 布局组件
81 | │ │ │ Theader.vue
82 | │ │ │ Nav.vue
83 | │ │ ├─pages // 基本组件
84 | │ │ │ E404.vue
85 | │ │ │ Login.vue
86 | │ │ │
87 | │ │ └─views // 业务组件
88 | │ │
89 | │ ├─router // 路由管理
90 | │ │
91 | │ └─store // 状态管理
92 | │
93 | ├─static // 业务静态资源
94 | │ └─img
95 | │
96 | └─test // 测试
97 | ├─e2e
98 | │ │ nightwatch.conf.js
99 | │ │ runner.js
100 | │ │
101 | │ ├─custom-assertions
102 | │ │ elementCount.js
103 | │ │
104 | │ └─specs
105 | │ test.js
106 | │
107 | └─unit
108 | │ .eslintrc
109 | │ index.js
110 | │ karma.conf.js
111 | │
112 | └─specs
113 | Hello.spec.js
114 | │ .babelrc // babel配置
115 | │ .editorconfig // editor配置
116 | │ .gitignore // git忽略配置
117 | │ .eslintrc.js // eslint配置
118 | │ .postcssrc.js // postcss配置
119 | │ index.html // 项目首页
120 | │ package.json // 依赖配置
121 | │ prod.server.js // 打包后启动文件
122 | ```
123 |
124 | > 代码默认遵循eslint(default)的规范 不习惯的可以在webpack.base.conf.js 关闭相应规则
125 |
126 | ## 浏览器支持
127 |
128 | * IE 9+
129 | * Firefox(最新)
130 | * Chrome(最新)
131 | * Safari(最新)
132 |
133 | ## Build Setup
134 |
135 | ``` bash
136 | # install dependencies
137 | npm install
138 |
139 | # 国内
140 | npm install --registry=https://registry.npm.taobao.org
141 |
142 | # serve with hot reload at localhost:8080
143 | npm run dev
144 |
145 | # build for production with minification
146 | npm run build
147 |
148 | # build for production and view the bundle analyzer report
149 | npm run build --report
150 |
151 | # run unit tests
152 | npm run unit
153 |
154 | # run e2e tests
155 | npm run e2e
156 |
157 | # run all tests
158 | npm test
159 | ```
160 |
161 | For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
162 |
--------------------------------------------------------------------------------
/build/build.js:
--------------------------------------------------------------------------------
1 | require('./check-versions')()
2 |
3 | process.env.NODE_ENV = 'production'
4 |
5 | var ora = require('ora')
6 | var rm = require('rimraf')
7 | var path = require('path')
8 | var chalk = require('chalk')
9 | var webpack = require('webpack')
10 | var config = require('../config')
11 | var webpackConfig = require('./webpack.prod.conf')
12 |
13 | var spinner = ora('building for production...')
14 | spinner.start()
15 |
16 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
17 | if (err) throw err
18 | webpack(webpackConfig, function (err, stats) {
19 | spinner.stop()
20 | if (err) throw err
21 | process.stdout.write(stats.toString({
22 | colors: true,
23 | modules: false,
24 | children: false,
25 | chunks: false,
26 | chunkModules: false
27 | }) + '\n\n')
28 |
29 | console.log(chalk.cyan(' Build complete.\n'))
30 | console.log(chalk.yellow(
31 | ' Tip: built files are meant to be served over an HTTP server.\n' +
32 | ' Opening index.html over file:// won\'t work.\n'
33 | ))
34 | })
35 | })
36 |
--------------------------------------------------------------------------------
/build/check-versions.js:
--------------------------------------------------------------------------------
1 | var chalk = require('chalk')
2 | var semver = require('semver')
3 | var packageConfig = require('../package.json')
4 | var shell = require('shelljs')
5 | function exec (cmd) {
6 | return require('child_process').execSync(cmd).toString().trim()
7 | }
8 |
9 | var versionRequirements = [
10 | {
11 | name: 'node',
12 | currentVersion: semver.clean(process.version),
13 | versionRequirement: packageConfig.engines.node
14 | },
15 | ]
16 |
17 | if (shell.which('npm')) {
18 | versionRequirements.push({
19 | name: 'npm',
20 | currentVersion: exec('npm --version'),
21 | versionRequirement: packageConfig.engines.npm
22 | })
23 | }
24 |
25 | module.exports = function () {
26 | var warnings = []
27 | for (var i = 0; i < versionRequirements.length; i++) {
28 | var mod = versionRequirements[i]
29 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
30 | warnings.push(mod.name + ': ' +
31 | chalk.red(mod.currentVersion) + ' should be ' +
32 | chalk.green(mod.versionRequirement)
33 | )
34 | }
35 | }
36 |
37 | if (warnings.length) {
38 | console.log('')
39 | console.log(chalk.yellow('To use this template, you must update following to modules:'))
40 | console.log()
41 | for (var i = 0; i < warnings.length; i++) {
42 | var warning = warnings[i]
43 | console.log(' ' + warning)
44 | }
45 | console.log()
46 | process.exit(1)
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/build/dev-client.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | require('eventsource-polyfill')
3 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
4 |
5 | hotClient.subscribe(function (event) {
6 | if (event.action === 'reload') {
7 | window.location.reload()
8 | }
9 | })
10 |
--------------------------------------------------------------------------------
/build/dev-server.js:
--------------------------------------------------------------------------------
1 | require('./check-versions')()
2 |
3 | var config = require('../config')
4 | if (!process.env.NODE_ENV) {
5 | process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
6 | }
7 |
8 | var opn = require('opn')
9 | var path = require('path')
10 | var express = require('express')
11 | var webpack = require('webpack')
12 | var proxyMiddleware = require('http-proxy-middleware')
13 | var webpackConfig = process.env.NODE_ENV === 'testing'
14 | ? require('./webpack.prod.conf')
15 | : require('./webpack.dev.conf')
16 |
17 | // default port where dev server listens for incoming traffic
18 | var port = process.env.PORT || config.dev.port
19 | // automatically open browser, if not set will be false
20 | var autoOpenBrowser = !!config.dev.autoOpenBrowser
21 | // Define HTTP proxies to your custom API backend
22 | // https://github.com/chimurai/http-proxy-middleware
23 | var proxyTable = config.dev.proxyTable
24 |
25 | var app = express()
26 | var compiler = webpack(webpackConfig)
27 |
28 | var devMiddleware = require('webpack-dev-middleware')(compiler, {
29 | publicPath: webpackConfig.output.publicPath,
30 | quiet: true
31 | })
32 |
33 | var hotMiddleware = require('webpack-hot-middleware')(compiler, {
34 | log: () => {}
35 | })
36 | // force page reload when html-webpack-plugin template changes
37 | compiler.plugin('compilation', function (compilation) {
38 | compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
39 | hotMiddleware.publish({ action: 'reload' })
40 | cb()
41 | })
42 | })
43 |
44 | // proxy api requests
45 | Object.keys(proxyTable).forEach(function (context) {
46 | var options = proxyTable[context]
47 | if (typeof options === 'string') {
48 | options = { target: options }
49 | }
50 | app.use(proxyMiddleware(options.filter || context, options))
51 | })
52 |
53 | // handle fallback for HTML5 history API
54 | app.use(require('connect-history-api-fallback')())
55 |
56 | // serve webpack bundle output
57 | app.use(devMiddleware)
58 |
59 | // enable hot-reload and state-preserving
60 | // compilation error display
61 | app.use(hotMiddleware)
62 |
63 | // serve pure static assets
64 | var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
65 | app.use(staticPath, express.static('./static'))
66 |
67 | var uri = 'http://localhost:' + port
68 |
69 | var _resolve
70 | var readyPromise = new Promise(resolve => {
71 | _resolve = resolve
72 | })
73 |
74 | console.log('> Starting dev server...')
75 | devMiddleware.waitUntilValid(() => {
76 | console.log('> Listening at ' + uri + '\n')
77 | // when env is testing, don't need open it
78 | if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
79 | opn(uri)
80 | }
81 | _resolve()
82 | })
83 |
84 | var server = app.listen(port)
85 |
86 | module.exports = {
87 | ready: readyPromise,
88 | close: () => {
89 | server.close()
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/build/utils.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var config = require('../config')
3 | var ExtractTextPlugin = require('extract-text-webpack-plugin')
4 |
5 | exports.assetsPath = function (_path) {
6 | var assetsSubDirectory = process.env.NODE_ENV === 'production'
7 | ? config.build.assetsSubDirectory
8 | : config.dev.assetsSubDirectory
9 | return path.posix.join(assetsSubDirectory, _path)
10 | }
11 |
12 | exports.cssLoaders = function (options) {
13 | options = options || {}
14 |
15 | var cssLoader = {
16 | loader: 'css-loader',
17 | options: {
18 | minimize: process.env.NODE_ENV === 'production',
19 | sourceMap: options.sourceMap
20 | }
21 | }
22 |
23 | // generate loader string to be used with extract text plugin
24 | function generateLoaders (loader, loaderOptions) {
25 | var loaders = [cssLoader]
26 | if (loader) {
27 | loaders.push({
28 | loader: loader + '-loader',
29 | options: Object.assign({}, loaderOptions, {
30 | sourceMap: options.sourceMap
31 | })
32 | })
33 | }
34 |
35 | // Extract CSS when that option is specified
36 | // (which is the case during production build)
37 | if (options.extract) {
38 | return ExtractTextPlugin.extract({
39 | use: loaders,
40 | fallback: 'vue-style-loader'
41 | })
42 | } else {
43 | return ['vue-style-loader'].concat(loaders)
44 | }
45 | }
46 |
47 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html
48 | return {
49 | css: generateLoaders(),
50 | postcss: generateLoaders(),
51 | less: generateLoaders('less'),
52 | sass: generateLoaders('sass', { indentedSyntax: true }),
53 | scss: generateLoaders('sass'),
54 | stylus: generateLoaders('stylus'),
55 | styl: generateLoaders('stylus')
56 | }
57 | }
58 |
59 | // Generate loaders for standalone style files (outside of .vue)
60 | exports.styleLoaders = function (options) {
61 | var output = []
62 | var loaders = exports.cssLoaders(options)
63 | for (var extension in loaders) {
64 | var loader = loaders[extension]
65 | output.push({
66 | test: new RegExp('\\.' + extension + '$'),
67 | use: loader
68 | })
69 | }
70 | return output
71 | }
72 |
--------------------------------------------------------------------------------
/build/vue-loader.conf.js:
--------------------------------------------------------------------------------
1 | var utils = require('./utils')
2 | var config = require('../config')
3 | var isProduction = process.env.NODE_ENV === 'production'
4 |
5 | module.exports = {
6 | loaders: utils.cssLoaders({
7 | sourceMap: isProduction
8 | ? config.build.productionSourceMap
9 | : config.dev.cssSourceMap,
10 | extract: isProduction
11 | })
12 | }
13 |
--------------------------------------------------------------------------------
/build/webpack.base.conf.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var utils = require('./utils')
3 | var config = require('../config')
4 | var vueLoaderConfig = require('./vue-loader.conf')
5 | var webpack = require('webpack')
6 | function resolve (dir) {
7 | return path.join(__dirname, '..', dir)
8 | }
9 |
10 | module.exports = {
11 | entry: {
12 | app: ['babel-polyfill', './src/main.js']
13 | },
14 | output: {
15 | path: config.build.assetsRoot,
16 | filename: '[name].js',
17 | publicPath: process.env.NODE_ENV === 'production'
18 | ? config.build.assetsPublicPath
19 | : config.dev.assetsPublicPath
20 | },
21 | resolve: {
22 | extensions: ['.js', '.vue', '.json'],
23 | alias: {
24 | 'vue$': 'vue/dist/vue.esm.js',
25 | '@': resolve('src')
26 | }
27 | },
28 | module: {
29 | rules: [
30 | {
31 | test: /\.(js|vue)$/,
32 | loader: 'eslint-loader',
33 | enforce: 'pre',
34 | include: [resolve('src'), resolve('test')],
35 | options: {
36 | formatter: require('eslint-friendly-formatter')
37 | }
38 | },
39 | {
40 | test: /\.vue$/,
41 | loader: 'vue-loader',
42 | options: vueLoaderConfig
43 | },
44 | { test: /iview.src.*?js$/, loader: 'babel-loader' },
45 | {
46 | test: /\.js$/,
47 | loader: 'babel-loader',
48 | include: [resolve('src'), resolve('test'), resolve('config')]
49 | },
50 | {
51 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
52 | loader: 'url-loader',
53 | options: {
54 | limit: 10000,
55 | name: utils.assetsPath('img/[name].[hash:7].[ext]')
56 | }
57 | },
58 | {
59 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
60 | loader: 'url-loader',
61 | options: {
62 | limit: 10000,
63 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
64 | }
65 | }
66 | ]
67 | },
68 | plugins: [
69 | new webpack.optimize.CommonsChunkPlugin('common.js'),
70 | new webpack.ProvidePlugin({
71 | jQuery: 'jquery',
72 | $: 'jquery'
73 | })
74 | ]
75 | }
76 |
--------------------------------------------------------------------------------
/build/webpack.dev.conf.js:
--------------------------------------------------------------------------------
1 | var utils = require('./utils')
2 | var webpack = require('webpack')
3 | var config = require('../config')
4 | var merge = require('webpack-merge')
5 | var baseWebpackConfig = require('./webpack.base.conf')
6 | var HtmlWebpackPlugin = require('html-webpack-plugin')
7 | var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
8 |
9 | // add hot-reload related code to entry chunks
10 | Object.keys(baseWebpackConfig.entry).forEach(function (name) {
11 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
12 | })
13 |
14 | module.exports = merge(baseWebpackConfig, {
15 | module: {
16 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
17 | },
18 | // cheap-module-eval-source-map is faster for development
19 | devtool: '#cheap-module-eval-source-map',
20 | plugins: [
21 | new webpack.DefinePlugin({
22 | 'process.env': config.dev.env
23 | }),
24 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
25 | new webpack.HotModuleReplacementPlugin(),
26 | new webpack.NoEmitOnErrorsPlugin(),
27 | // https://github.com/ampedandwired/html-webpack-plugin
28 | new HtmlWebpackPlugin({
29 | filename: 'index.html',
30 | template: 'index.html',
31 | inject: true
32 | }),
33 | new FriendlyErrorsPlugin()
34 | ]
35 | })
36 |
--------------------------------------------------------------------------------
/build/webpack.prod.conf.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var utils = require('./utils')
3 | var webpack = require('webpack')
4 | var config = require('../config')
5 | var merge = require('webpack-merge')
6 | var baseWebpackConfig = require('./webpack.base.conf')
7 | var CopyWebpackPlugin = require('copy-webpack-plugin')
8 | var HtmlWebpackPlugin = require('html-webpack-plugin')
9 | var ExtractTextPlugin = require('extract-text-webpack-plugin')
10 | var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
11 |
12 | var env = process.env.NODE_ENV === 'testing'
13 | ? require('../config/test.env')
14 | : config.build.env
15 |
16 | var webpackConfig = merge(baseWebpackConfig, {
17 | module: {
18 | rules: utils.styleLoaders({
19 | sourceMap: config.build.productionSourceMap,
20 | extract: true
21 | })
22 | },
23 | devtool: config.build.productionSourceMap ? '#source-map' : false,
24 | output: {
25 | path: config.build.assetsRoot,
26 | filename: utils.assetsPath('js/[name].[chunkhash].js'),
27 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
28 | },
29 | plugins: [
30 | // http://vuejs.github.io/vue-loader/en/workflow/production.html
31 | new webpack.DefinePlugin({
32 | 'process.env': env
33 | }),
34 | new webpack.optimize.UglifyJsPlugin({
35 | compress: {
36 | warnings: false
37 | },
38 | sourceMap: true
39 | }),
40 | // extract css into its own file
41 | new ExtractTextPlugin({
42 | filename: utils.assetsPath('css/[name].[contenthash].css')
43 | }),
44 | // Compress extracted CSS. We are using this plugin so that possible
45 | // duplicated CSS from different components can be deduped.
46 | new OptimizeCSSPlugin({
47 | cssProcessorOptions: {
48 | safe: true
49 | }
50 | }),
51 | // generate dist index.html with correct asset hash for caching.
52 | // you can customize output by editing /index.html
53 | // see https://github.com/ampedandwired/html-webpack-plugin
54 | new HtmlWebpackPlugin({
55 | filename: process.env.NODE_ENV === 'testing'
56 | ? 'index.html'
57 | : config.build.index,
58 | template: 'index.html',
59 | inject: true,
60 | minify: {
61 | removeComments: true,
62 | collapseWhitespace: true,
63 | removeAttributeQuotes: true
64 | // more options:
65 | // https://github.com/kangax/html-minifier#options-quick-reference
66 | },
67 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin
68 | chunksSortMode: 'dependency'
69 | }),
70 | // split vendor js into its own file
71 | new webpack.optimize.CommonsChunkPlugin({
72 | name: 'vendor',
73 | minChunks: function (module, count) {
74 | // any required modules inside node_modules are extracted to vendor
75 | return (
76 | module.resource &&
77 | /\.js$/.test(module.resource) &&
78 | module.resource.indexOf(
79 | path.join(__dirname, '../node_modules')
80 | ) === 0
81 | )
82 | }
83 | }),
84 | // extract webpack runtime and module manifest to its own file in order to
85 | // prevent vendor hash from being updated whenever app bundle is updated
86 | new webpack.optimize.CommonsChunkPlugin({
87 | name: 'manifest',
88 | chunks: ['vendor']
89 | }),
90 | // copy custom static assets
91 | new CopyWebpackPlugin([
92 | {
93 | from: path.resolve(__dirname, '../static'),
94 | to: config.build.assetsSubDirectory,
95 | ignore: ['.*']
96 | }
97 | ])
98 | ]
99 | })
100 |
101 | if (config.build.productionGzip) {
102 | var CompressionWebpackPlugin = require('compression-webpack-plugin')
103 |
104 | webpackConfig.plugins.push(
105 | new CompressionWebpackPlugin({
106 | asset: '[path].gz[query]',
107 | algorithm: 'gzip',
108 | test: new RegExp(
109 | '\\.(' +
110 | config.build.productionGzipExtensions.join('|') +
111 | ')$'
112 | ),
113 | threshold: 10240,
114 | minRatio: 0.8
115 | })
116 | )
117 | }
118 |
119 | if (config.build.bundleAnalyzerReport) {
120 | var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
121 | webpackConfig.plugins.push(new BundleAnalyzerPlugin())
122 | }
123 |
124 | module.exports = webpackConfig
125 |
--------------------------------------------------------------------------------
/build/webpack.test.conf.js:
--------------------------------------------------------------------------------
1 | // This is the webpack config used for unit tests.
2 |
3 | var utils = require('./utils')
4 | var webpack = require('webpack')
5 | var merge = require('webpack-merge')
6 | var baseConfig = require('./webpack.base.conf')
7 |
8 | var webpackConfig = merge(baseConfig, {
9 | // use inline sourcemap for karma-sourcemap-loader
10 | module: {
11 | rules: utils.styleLoaders()
12 | },
13 | devtool: '#inline-source-map',
14 | resolveLoader: {
15 | alias: {
16 | // necessary to to make lang="scss" work in test when using vue-loader's ?inject option
17 | // see discussion at https://github.com/vuejs/vue-loader/issues/724
18 | 'scss-loader': 'sass-loader'
19 | }
20 | },
21 | plugins: [
22 | new webpack.DefinePlugin({
23 | 'process.env': require('../config/test.env')
24 | })
25 | ]
26 | })
27 |
28 | // no need for app entry during tests
29 | delete webpackConfig.entry
30 |
31 | module.exports = webpackConfig
32 |
--------------------------------------------------------------------------------
/config/dev.env.js:
--------------------------------------------------------------------------------
1 | var merge = require('webpack-merge')
2 | var prodEnv = require('./prod.env')
3 |
4 | module.exports = merge(prodEnv, {
5 | NODE_ENV: '"development"'
6 | })
7 |
--------------------------------------------------------------------------------
/config/index.js:
--------------------------------------------------------------------------------
1 | // see http://vuejs-templates.github.io/webpack for documentation.
2 | var path = require('path')
3 |
4 | var config = {
5 | build: {
6 | env: require('./prod.env'),
7 | port: 9000,
8 | index: path.resolve(__dirname, '../dist/index.html'),
9 | assetsRoot: path.resolve(__dirname, '../dist'),
10 | assetsSubDirectory: 'static',
11 | assetsPublicPath: '/',
12 | baseServerUrl: 'http://gank.io',
13 | productionSourceMap: true,
14 | // Gzip off by default as many popular static hosts such as
15 | // Surge or Netlify already gzip all static assets for you.
16 | // Before setting to `true`, make sure to:
17 | // npm install --save-dev compression-webpack-plugin
18 | productionGzip: false,
19 | productionGzipExtensions: ['js', 'css'],
20 | // Run the build command with an extra argument to
21 | // View the bundle analyzer report after build finishes:
22 | // `npm run build --report`
23 | // Set to `true` or `false` to always turn it on or off
24 | bundleAnalyzerReport: process.env.npm_config_report
25 | },
26 | dev: {
27 | env: require('./dev.env'),
28 | port: 9999,
29 | autoOpenBrowser: true,
30 | assetsSubDirectory: 'static',
31 | assetsPublicPath: '/',
32 | baseServerUrl: 'http://gank.io',
33 | proxyTable: {},
34 | // CSS Sourcemaps off by default because relative paths are "buggy"
35 | // with this option, according to the CSS-Loader README
36 | // (https://github.com/webpack/css-loader#sourcemaps)
37 | // In our experience, they generally work as expected,
38 | // just be aware of this issue when enabling this option.
39 | cssSourceMap: false
40 | }
41 | }
42 |
43 | // 需要代理的接口
44 | var proxyList = [
45 | '/*/person/**/*'
46 | ]
47 |
48 | const targetPath = config.dev.baseServerUrl // 服务器的地址 可以使www.xx.com
49 |
50 | for (let i = 0; i < proxyList.length; i++) {
51 | config.dev.proxyTable[proxyList[i]] = {
52 | target: targetPath,
53 | secure: false,
54 | changeOrigin: true
55 | }
56 | }
57 | // console.info(Object.keys(config.dev.proxyTable))
58 | module.exports = config
59 |
--------------------------------------------------------------------------------
/config/prod.env.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | NODE_ENV: '"production"'
3 | }
4 |
--------------------------------------------------------------------------------
/config/test.env.js:
--------------------------------------------------------------------------------
1 | var merge = require('webpack-merge')
2 | var devEnv = require('./dev.env')
3 |
4 | module.exports = merge(devEnv, {
5 | NODE_ENV: '"testing"'
6 | })
7 |
--------------------------------------------------------------------------------
/dist/index.html:
--------------------------------------------------------------------------------
1 |