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.
 
 
 
 

99 lines
2.2 KiB

  1. var path = require('path')
  2. var fs = require('fs')
  3. const nodeModules = fs.readdirSync("node_modules").filter(function(x) { return x !== ".bin" })
  4. var ExtractTextPlugin = require('extract-text-webpack-plugin')
  5. var rules = [
  6. { test: /\.(worker\.js)(\?.*)?$/,
  7. use: [
  8. {
  9. loader: 'worker-loader',
  10. options: {
  11. inline: true,
  12. name: '[name].js'
  13. }
  14. },
  15. { loader: 'babel-loader' }
  16. ]
  17. },
  18. { test: /\.(css)(\?.*)?$/,
  19. use: ExtractTextPlugin.extract({
  20. fallback: 'style-loader',
  21. use: [
  22. 'css-loader',
  23. 'postcss-loader'
  24. ]
  25. })
  26. },
  27. { test: /\.(scss)(\?.*)?$/,
  28. use: ExtractTextPlugin.extract({
  29. fallback: 'style-loader',
  30. use: [
  31. {
  32. loader: 'css-loader',
  33. options: { minimize: true }
  34. },
  35. {
  36. loader: 'postcss-loader',
  37. options: { sourceMap: true }
  38. },
  39. { loader: 'sass-loader',
  40. options: {
  41. outputStyle: 'expanded',
  42. sourceMap: true,
  43. sourceMapContents: 'true'
  44. }
  45. }
  46. ]
  47. })
  48. },
  49. { test: /\.(less)(\?.*)?$/,
  50. use: ExtractTextPlugin.extract({
  51. fallback: 'style-loader',
  52. use: ['css-loader',
  53. {
  54. loader: 'postcss-loader',
  55. },
  56. 'less-loader'
  57. ]
  58. })
  59. }
  60. ]
  61. module.exports = require('./make-webpack-config.js')(rules, {
  62. _special: {
  63. separateStylesheets: true,
  64. minimize: true,
  65. sourcemaps: true,
  66. },
  67. entry: {
  68. "swagger-ui": [
  69. "./src/style/main.scss",
  70. "./src/polyfills",
  71. "./src/core/index.js"
  72. ]
  73. },
  74. externals: function(context, request, cb) {
  75. // webpack injects some stuff into the resulting file,
  76. // these libs need to be pulled in to keep that working.
  77. var exceptionsForWebpack = ["ieee754", "base64-js"]
  78. if(nodeModules.indexOf(request) !== -1 || exceptionsForWebpack.indexOf(request) !== -1) {
  79. cb(null, "commonjs " + request)
  80. return
  81. }
  82. cb()
  83. },
  84. output: {
  85. path: path.join(__dirname, "dist"),
  86. publicPath: "/dist",
  87. library: "SwaggerUICore",
  88. libraryTarget: "umd",
  89. filename: "[name].js",
  90. chunkFilename: "js/[name].js",
  91. },
  92. })