项目作者: zhoou

项目描述 :
vue-cli-multipage-bootstrap demo with vue2+vue-router+vuex+bootstrap+markdown for learning vue2.0
高级语言: Vue
项目地址: git://github.com/zhoou/vue-cli-multipage-bootstrap.git
创建时间: 2016-11-11T10:16:21Z
项目社区:https://github.com/zhoou/vue-cli-multipage-bootstrap

开源协议:

下载


Vue Learn

A Vue.js2.0 project with Bootstrap which integrated the vue official online examples to components and some components build by myself to anyone who interested in .


vue-cli-multipage-bootstrap-new
vue-cli-multipage-bootstrap

Components

Dev Environment

npm install

npm run dev

The initial access path:

you can click the nav ‘案例:Examples’ and choice ‘TableHome’ to jump to another project ‘tablehome.html’.

Prod Environment

npm install

npm run build

Please take the published content to the local server IIS or on another server you like ,

and then the initial access path :(serverIP)/officialdemo.html

Build Setup

  1. # 安装vue-cli
  2. npm install -g vue-cli
  3. # 使用vue-cli初始化项目
  4. vue init webpack my-project
  5. # 进入到目录
  6. cd my-project
  7. # install dependencies
  8. npm install
  9. # serve with hot reload at localhost:8080
  10. npm run dev
  11. # build for production with minification
  12. npm run build
  13. # run unit tests
  14. npm run unit
  15. # run e2e tests
  16. npm run e2e
  17. # run all tests
  18. npm test

多页面配置

webpack.base.conf.js 配置:

  1. var entries = getEntry('./src/module/*/*.js'); // 获得入口js文件
  2. function getEntry(globPath) {
  3. var entries = {},
  4. basename, tmp, pathname;
  5. glob.sync(globPath).forEach(function (entry) {
  6. basename = path.basename(entry, path.extname(entry));
  7. tmp = entry.split('/').splice(-3);
  8. pathname = tmp.splice(1, 1).toString().toLowerCase(); // 正确输出js和html的路径
  9. entries[pathname] = entry;
  10. });
  11. return entries;
  12. }
其中入口entry修改成如下:
  1. entry: Object.assign(entries,{
  2. vendors : ['jquery', 'bootstrap']
  3. })

webpack.dev.conf.js 配置:

  1. function getEntry(globPath) {
  2. var entries = {},
  3. basename, tmp, pathname;
  4. glob.sync(globPath).forEach(function (entry) {
  5. basename = path.basename(entry, path.extname(entry));
  6. tmp = entry.split('/').splice(-3);
  7. pathname = tmp.splice(1, 1).toString().toLowerCase();
  8. entries[pathname] = entry;
  9. });
  10. return entries;
  11. }
  12. var pages = getEntry('./src/module/**/*.html');
  13. for (var pathname in pages) {
  14. // 配置生成的html文件,定义路径等
  15. var conf = {
  16. filename: pathname + '.html',
  17. template: pages[pathname], // 模板路径
  18. inject: true // js插入位置
  19. };
  20. // 需要生成几个html文件,就配置几个HtmlWebpackPlugin对象
  21. module.exports.plugins.push(new HtmlWebpackPlugin(conf));
  22. }

webpack.prod.conf.js 配置:

  1. function getEntry(globPath) {
  2. var entries = {},
  3. basename, tmp, pathname;
  4. glob.sync(globPath).forEach(function (entry) {
  5. basename = path.basename(entry, path.extname(entry));
  6. tmp = entry.split('/').splice(-3);
  7. pathname = tmp.splice(1, 1).toString().toLowerCase();
  8. entries[pathname] = entry;
  9. });
  10. return entries;
  11. }
  12. var pages = getEntry('./src/module/*/*.html');
  13. for (var pathname in pages) {
  14. // 配置生成的html文件,定义路径等
  15. var conf = {
  16. filename: pathname + '.html',
  17. template: pages[pathname], // 模板路径
  18. inject: true, // js插入位置
  19. minify: {
  20. removeComments: true,
  21. collapseWhitespace: true,
  22. removeAttributeQuotes: true
  23. // more options:
  24. // https://github.com/kangax/html-minifier#options-quick-reference
  25. },
  26. // necessary to consistently work with multiple chunks via CommonsChunkPlugin
  27. chunksSortMode: 'dependency'
  28. };
  29. // 需要生成几个html文件,就配置几个HtmlWebpackPlugin对象
  30. webpackConfig.plugins.push(new HtmlWebpackPlugin(conf));
  31. }

markdown配置

详见:build\webpack.markdown.js
主要使用的插件:markdown-it

Welcome guidance !!