跳板机管理web端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.9 KiB

8 years ago
  1. var path = require('path')
  2. var config = require('../config')
  3. var ExtractTextPlugin = require('extract-text-webpack-plugin')
  4. exports.assetsPath = function (_path) {
  5. var assetsSubDirectory = process.env.NODE_ENV === 'production'
  6. ? config.build.assetsSubDirectory
  7. : config.dev.assetsSubDirectory
  8. return path.posix.join(assetsSubDirectory, _path)
  9. }
  10. exports.cssLoaders = function (options) {
  11. options = options || {}
  12. // generate loader string to be used with extract text plugin
  13. function generateLoaders (loaders) {
  14. var sourceLoader = loaders.map(function (loader) {
  15. var extraParamChar
  16. if (/\?/.test(loader)) {
  17. loader = loader.replace(/\?/, '-loader?')
  18. extraParamChar = '&'
  19. } else {
  20. loader = loader + '-loader'
  21. extraParamChar = '?'
  22. }
  23. return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
  24. }).join('!')
  25. // Extract CSS when that option is specified
  26. // (which is the case during production build)
  27. if (options.extract) {
  28. return ExtractTextPlugin.extract('vue-style-loader', sourceLoader)
  29. } else {
  30. return ['vue-style-loader', sourceLoader].join('!')
  31. }
  32. }
  33. // http://vuejs.github.io/vue-loader/en/configurations/extract-css.html
  34. return {
  35. css: generateLoaders(['css']),
  36. postcss: generateLoaders(['css']),
  37. less: generateLoaders(['css', 'less']),
  38. sass: generateLoaders(['css', 'sass?indentedSyntax']),
  39. scss: generateLoaders(['css', 'sass']),
  40. stylus: generateLoaders(['css', 'stylus']),
  41. styl: generateLoaders(['css', 'stylus'])
  42. }
  43. }
  44. // Generate loaders for standalone style files (outside of .vue)
  45. exports.styleLoaders = function (options) {
  46. var output = []
  47. var loaders = exports.cssLoaders(options)
  48. for (var extension in loaders) {
  49. var loader = loaders[extension]
  50. output.push({
  51. test: new RegExp('\\.' + extension + '$'),
  52. loader: loader
  53. })
  54. }
  55. return output
  56. }