Timers and other features for Heroes of the Storm
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.
 
 
 
 
 

90 lines
2.6 KiB

  1. /*
  2. * Copyright © 2021 Adrien Agez <adrien.agez@pm.me>
  3. *
  4. * This file is part of Nexus Timers.
  5. *
  6. * Nexus Timers is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Nexus Timers is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with Nexus Timers. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. 'use strict'
  20. const path = require('path')
  21. const config = require('../config')
  22. const ExtractTextPlugin = require('extract-text-webpack-plugin')
  23. exports.assetsPath = function (_path) {
  24. const assetsSubDirectory = process.env.NODE_ENV === 'production'
  25. ? config.build.assetsSubDirectory
  26. : config.dev.assetsSubDirectory
  27. return path.posix.join(assetsSubDirectory, _path)
  28. }
  29. exports.cssLoaders = function (options) {
  30. options = options || {}
  31. const cssLoader = {
  32. loader: 'css-loader',
  33. options: {
  34. minimize: process.env.NODE_ENV === 'production',
  35. sourceMap: options.sourceMap
  36. }
  37. }
  38. // generate loader string to be used with extract text plugin
  39. function generateLoaders (loader, loaderOptions) {
  40. const loaders = [cssLoader]
  41. if (loader) {
  42. loaders.push({
  43. loader: loader + '-loader',
  44. options: Object.assign({}, loaderOptions, {
  45. sourceMap: options.sourceMap
  46. })
  47. })
  48. }
  49. // Extract CSS when that option is specified
  50. // (which is the case during production build)
  51. if (options.extract) {
  52. return ExtractTextPlugin.extract({
  53. use: loaders,
  54. fallback: 'vue-style-loader'
  55. })
  56. } else {
  57. return ['vue-style-loader'].concat(loaders)
  58. }
  59. }
  60. // https://vue-loader.vuejs.org/en/configurations/extract-css.html
  61. return {
  62. css: generateLoaders(),
  63. postcss: generateLoaders(),
  64. sass: generateLoaders('sass', { indentedSyntax: true, data: `@import @/styles/main.sass` }),
  65. scss: generateLoaders('sass'),
  66. }
  67. }
  68. // Generate loaders for standalone style files (outside of .vue)
  69. exports.styleLoaders = function (options) {
  70. const output = []
  71. const loaders = exports.cssLoaders(options)
  72. for (const extension in loaders) {
  73. const loader = loaders[extension]
  74. output.push({
  75. test: new RegExp('\\.' + extension + '$'),
  76. use: loader
  77. })
  78. }
  79. return output
  80. }