Timers and other features for Heroes of the Storm
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

utils.js 1.9 KiB

há 4 anos
há 4 anos
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. 'use strict'
  2. const path = require('path')
  3. const config = require('../config')
  4. const ExtractTextPlugin = require('extract-text-webpack-plugin')
  5. exports.assetsPath = function (_path) {
  6. const assetsSubDirectory = process.env.NODE_ENV === 'production'
  7. ? config.build.assetsSubDirectory
  8. : config.dev.assetsSubDirectory
  9. return path.posix.join(assetsSubDirectory, _path)
  10. }
  11. exports.cssLoaders = function (options) {
  12. options = options || {}
  13. const cssLoader = {
  14. loader: 'css-loader',
  15. options: {
  16. minimize: process.env.NODE_ENV === 'production',
  17. sourceMap: options.sourceMap
  18. }
  19. }
  20. // generate loader string to be used with extract text plugin
  21. function generateLoaders (loader, loaderOptions) {
  22. const loaders = [cssLoader]
  23. if (loader) {
  24. loaders.push({
  25. loader: loader + '-loader',
  26. options: Object.assign({}, loaderOptions, {
  27. sourceMap: options.sourceMap
  28. })
  29. })
  30. }
  31. // Extract CSS when that option is specified
  32. // (which is the case during production build)
  33. if (options.extract) {
  34. return ExtractTextPlugin.extract({
  35. use: loaders,
  36. fallback: 'vue-style-loader'
  37. })
  38. } else {
  39. return ['vue-style-loader'].concat(loaders)
  40. }
  41. }
  42. // https://vue-loader.vuejs.org/en/configurations/extract-css.html
  43. return {
  44. css: generateLoaders(),
  45. postcss: generateLoaders(),
  46. sass: generateLoaders('sass', { indentedSyntax: true, data: `@import @/styles/main.sass` }),
  47. scss: generateLoaders('sass'),
  48. }
  49. }
  50. // Generate loaders for standalone style files (outside of .vue)
  51. exports.styleLoaders = function (options) {
  52. const output = []
  53. const loaders = exports.cssLoaders(options)
  54. for (const extension in loaders) {
  55. const loader = loaders[extension]
  56. output.push({
  57. test: new RegExp('\\.' + extension + '$'),
  58. use: loader
  59. })
  60. }
  61. return output
  62. }