changtimwu / changtimwu.github.com

Tim's testing/practice notes
7 stars 2 forks source link

VueJS & PostCSS #73

Open changtimwu opened 7 years ago

changtimwu commented 7 years ago

official doc https://vue-loader.vuejs.org/en/features/postcss.html

Trace

How to use sugarss in VUE?

Documents of VUE loader mention postcss

A loader ex.( pug-loader, postcss-loader) only load standalone file of its own type. How does vue-loader conjunct them ?

module.exports = {
module: { rules: [ { test: /.vue$/,
loader: 'vue-loader', options: vueLoaderConfig
} ] }


* in `build/vue-loader.conf.js`
``` js
var utils = require('./utils')
var config = require('../config')
var isProduction = process.env.NODE_ENV === 'production'

module.exports = {
  loaders: utils.cssLoaders({
    sourceMap: isProduction ? config.build.productionSourceMap : config.dev.cssSourceMap,
    extract: isProduction
  }),
  cssModules: {
    localIdentName: '[path][name]---[local]---[hash:base64:5]',
    camelCase: true
  }
}
changtimwu commented 7 years ago

https://www.npmjs.com/package/postcss-loader

list all factors

modules

necessary

config files

changtimwu commented 7 years ago

disable opening a new browser tab every time rpm run dev

edit file config/index.js


module.exports = {
  build: {  
     ....
  },
  dev: {
    ....
    autoOpenBrowser: false
  }
}
changtimwu commented 7 years ago

store modules journey of an action using GetInfo action as an example.

changtimwu commented 7 years ago

please note that router is under store. router is used by the permission module in store. Actually the store depends quite a lot stuff. Not sure if this is a good practice. Doesn't this make store hard to standalone test?

main ---------------------> router
           +------------------> store

store ---------> router
           +-------> api/login
           +-------> cookie                      

This is really a mess. Cyclic access.

store -->  api/login ----> utils/fetch  --> store 

Well, that's explainable. It references the store in service's interceptors. In that way every request via fetch would automatically check token in header.

just use upper case for all mutations instead of constants that vuex proposes

 mutations: {
    SET_AUTH_TYPE: (state, type) => {
      state.auth_type = type;
    },
    SET_CODE: (state, code) => {
      state.code = code;
    },
    SET_TOKEN: (state, token) => {
      state.token = token;
    },
}
changtimwu commented 7 years ago

web framework https://github.com/get-ion/ion

using JWT in SPA. In a typical SPA application, we let user login with http form post, which is not json style API. And the server validates the user and returns a token. Then later API accesses must include this token.

JWT is actually an unified way make the login procedure not dependent on form post. It's a login in the form of web API. So your API server can be a pure API instead of required to bother the form post stuff.

changtimwu commented 6 years ago

try this on lambda some other day http://www.jianshu.com/p/08fab8d4ee35

https://htmlpreview.github.io/?https://raw.githubusercontent.com/Miserlou/Talks/master/serverless-sf/big.quickstart.html#91