Skip to content

Instantly share code, notes, and snippets.

@njleonzhang
Last active November 16, 2017 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njleonzhang/bbc451299e04d7b756fa8cec303482b5 to your computer and use it in GitHub Desktop.
Save njleonzhang/bbc451299e04d7b756fa8cec303482b5 to your computer and use it in GitHub Desktop.
my vue template change
  1. sass
cnpm install sass-loader node-sass --save-dev
  1. pug
cnpm install pug --save-dev
  1. sass-resources-loader
cnpm install sass-resources-loader --save-dev

in build/utils.js, add

scss: generateLoaders('sass').concat(
  {
    loader: 'sass-resources-loader',
    options: {
      resources: path.resolve(__dirname, '../src/style/_variables.scss')
    }
  }
),
  1. proxy config in config/dev.env.js add httpBaseUrl
{
  module.exports = merge(prodEnv, {
    NODE_ENV: '"development"',
    httpBaseUrl: `"/api/"`
  })
}

in config/index.js add const ip = require('ip')

dev: {
  host: `${ip.address()}`,
  proxyTable: {
    '/api': {
      target: '------真实服务器地址-----',
      changeOrigin: true,
      pathRewrite: {
        '^/api': ''
      }
    }
  }
}

in config/prod.js add

module.exports = {
  NODE_ENV: '"production"',
  httpBaseUrl: '"/"'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment