webpack.config.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. const webpack = require("webpack");
  2. const ExtractTextPlugin = require("extract-text-webpack-plugin");
  3. const path = require("path");
  4. /**
  5. * Webpack configuration details for use with Grunt.
  6. *
  7. * @author n1474335 [n1474335@gmail.com]
  8. * @copyright Crown Copyright 2017
  9. * @license Apache-2.0
  10. */
  11. const banner = `/**
  12. * CyberChef - The Cyber Swiss Army Knife
  13. *
  14. * @copyright Crown Copyright 2016
  15. * @license Apache-2.0
  16. *
  17. * Copyright 2016 Crown Copyright
  18. *
  19. * Licensed under the Apache License, Version 2.0 (the "License");
  20. * you may not use this file except in compliance with the License.
  21. * You may obtain a copy of the License at
  22. *
  23. * http://www.apache.org/licenses/LICENSE-2.0
  24. *
  25. * Unless required by applicable law or agreed to in writing, software
  26. * distributed under the License is distributed on an "AS IS" BASIS,
  27. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  28. * See the License for the specific language governing permissions and
  29. * limitations under the License.
  30. */`;
  31. const vendorCSS = new ExtractTextPlugin("vendor.css");
  32. const projectCSS = new ExtractTextPlugin("styles.css");
  33. module.exports = {
  34. plugins: [
  35. new webpack.ProvidePlugin({
  36. $: "jquery",
  37. jQuery: "jquery",
  38. log: "loglevel"
  39. }),
  40. new webpack.BannerPlugin({
  41. banner: banner,
  42. raw: true,
  43. entryOnly: true
  44. }),
  45. vendorCSS,
  46. projectCSS
  47. ],
  48. resolve: {
  49. alias: {
  50. jquery: "jquery/src/jquery",
  51. },
  52. },
  53. module: {
  54. rules: [
  55. {
  56. test: /\.m?js$/,
  57. exclude: /node_modules\/(?!jsesc|crypto-api)/,
  58. options: {
  59. configFile: path.resolve(__dirname, "babel.config.js"),
  60. cacheDirectory: true,
  61. compact: false
  62. },
  63. type: "javascript/auto",
  64. loader: "babel-loader"
  65. },
  66. {
  67. test: /forge.min.js$/,
  68. loader: "imports-loader?jQuery=>null"
  69. },
  70. {
  71. test: /bootstrap-material-design/,
  72. loader: "imports-loader?Popper=popper.js/dist/umd/popper.js"
  73. },
  74. {
  75. test: /\.css$/,
  76. use: projectCSS.extract({
  77. use: [
  78. { loader: "css-loader" },
  79. { loader: "postcss-loader" },
  80. ]
  81. })
  82. },
  83. {
  84. test: /\.scss$/,
  85. use: vendorCSS.extract({
  86. use: [
  87. { loader: "css-loader" },
  88. { loader: "sass-loader" }
  89. ]
  90. })
  91. },
  92. {
  93. test: /\.(ico|eot|ttf|woff|woff2)$/,
  94. loader: "url-loader",
  95. options: {
  96. limit: 10000
  97. }
  98. },
  99. { // First party images are saved as files to be cached
  100. test: /\.(png|jpg|gif|svg)$/,
  101. exclude: /node_modules/,
  102. loader: "file-loader",
  103. options: {
  104. name: "images/[name].[ext]"
  105. }
  106. },
  107. { // Third party images are inlined
  108. test: /\.(png|jpg|gif|svg)$/,
  109. exclude: /web\/static/,
  110. loader: "url-loader",
  111. options: {
  112. limit: 10000
  113. }
  114. },
  115. ]
  116. },
  117. stats: {
  118. children: false,
  119. chunks: false,
  120. modules: false,
  121. entrypoints: false,
  122. warningsFilter: [
  123. /source-map/,
  124. /dependency is an expression/,
  125. /export 'default'/
  126. ],
  127. },
  128. node: {
  129. fs: "empty"
  130. },
  131. performance: {
  132. hints: false
  133. }
  134. };