Authored by ccbikai

add vue loader

@@ -13,7 +13,10 @@ const helpers = global.yoho.helpers; @@ -13,7 +13,10 @@ const helpers = global.yoho.helpers;
13 */ 13 */
14 const channel = { 14 const channel = {
15 index: (req, res, next) => { 15 index: (req, res, next) => {
16 - res.render('index'); 16 + res.render('index', {
  17 + module: 'channel',
  18 + page: 'home'
  19 + });
17 } 20 }
18 }; 21 };
19 22
1 -<h1>Index</h1>  
  1 +<h1>Index</h1>
  2 +<div id="app">
  3 + <app></app>
  4 +</div>
@@ -49,6 +49,12 @@ @@ -49,6 +49,12 @@
49 }, 49 },
50 "devDependencies": { 50 "devDependencies": {
51 "autoprefixer": "^6.3.7", 51 "autoprefixer": "^6.3.7",
  52 + "babel-core": "^6.10.4",
  53 + "babel-loader": "^6.2.4",
  54 + "babel-plugin-transform-runtime": "^6.9.0",
  55 + "babel-preset-es2015": "^6.9.0",
  56 + "babel-runtime": "^6.9.2",
  57 + "css-loader": "^0.23.1",
52 "eslint": "^3.0.1", 58 "eslint": "^3.0.1",
53 "eslint-config-yoho": "^1.0.1", 59 "eslint-config-yoho": "^1.0.1",
54 "gulp": "^3.9.1", 60 "gulp": "^3.9.1",
@@ -74,6 +80,10 @@ @@ -74,6 +80,10 @@
74 "shelljs": "^0.7.0", 80 "shelljs": "^0.7.0",
75 "stylelint": "^6.9.0", 81 "stylelint": "^6.9.0",
76 "stylelint-config-yoho": "^1.2.3", 82 "stylelint-config-yoho": "^1.2.3",
  83 + "vue-hot-reload-api": "^1.3.3",
  84 + "vue-html-loader": "^1.2.3",
  85 + "vue-loader": "^8.5.3",
  86 + "vue-style-loader": "^1.0.0",
77 "webpack": "^1.13.1", 87 "webpack": "^1.13.1",
78 "webpack-dev-server": "^1.14.1", 88 "webpack-dev-server": "^1.14.1",
79 "webpack-stream": "^3.1.0", 89 "webpack-stream": "^3.1.0",
@@ -83,6 +93,7 @@ @@ -83,6 +93,7 @@
83 "yoho-jquery-lazyload": "^1.9.7", 93 "yoho-jquery-lazyload": "^1.9.7",
84 "yoho-mlellipsis": "0.0.3", 94 "yoho-mlellipsis": "0.0.3",
85 "yoho-node-lib": "0.0.17", 95 "yoho-node-lib": "0.0.17",
86 - "yoho-swiper": "^3.3.1" 96 + "yoho-swiper": "^3.3.1",
  97 + "yoho-vue": "^1.0.26"
87 } 98 }
88 } 99 }
  1 +var Vue = require('yoho-vue');
  2 +
  3 +var App = require('channel/home');
  4 +
  5 +new Vue({
  6 + el: '#app',
  7 + components: {
  8 + app: App
  9 + }
  10 +})
  1 +<template>
  2 + <div class="test">
  3 + {{message}}
  4 + </div>
  5 +</template>
  6 +
  7 +<script>
  8 + module.exports = {
  9 + data: function() {
  10 + return {
  11 + message: 'test'
  12 + }
  13 + }
  14 + }
  15 +</script>
  16 +
  17 +<style>
  18 + .test {
  19 + color: green;
  20 + }
  21 +</style>
@@ -37,6 +37,16 @@ module.exports = { @@ -37,6 +37,16 @@ module.exports = {
37 path: path.join(__dirname, 'bundle'), // absolute path 37 path: path.join(__dirname, 'bundle'), // absolute path
38 filename: '[name].js' 38 filename: '[name].js'
39 }, 39 },
  40 + module: {
  41 + loaders: [{
  42 + test: /\.vue$/,
  43 + loader: 'vue'
  44 + }]
  45 + },
  46 + resolve: {
  47 + extensions: ['', '.vue', '.js'],
  48 + modulesDirectories: ['node_modules', './vue']
  49 + },
40 plugins: [ 50 plugins: [
41 new webpack.optimize.OccurenceOrderPlugin(), 51 new webpack.optimize.OccurenceOrderPlugin(),
42 new webpack.optimize.CommonsChunkPlugin({ 52 new webpack.optimize.CommonsChunkPlugin({