webpack.config.js 3.6 KB

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