webpack.config.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. const vendorCSS = new ExtractTextPlugin("vendor.css");
  31. const projectCSS = new ExtractTextPlugin("styles.css");
  32. module.exports = {
  33. plugins: [
  34. new webpack.ProvidePlugin({
  35. $: "jquery",
  36. jQuery: "jquery",
  37. log: "loglevel"
  38. }),
  39. new webpack.BannerPlugin({
  40. banner: banner,
  41. raw: true,
  42. entryOnly: true
  43. }),
  44. vendorCSS,
  45. projectCSS
  46. ],
  47. resolve: {
  48. alias: {
  49. jquery: "jquery/src/jquery",
  50. },
  51. },
  52. module: {
  53. rules: [
  54. {
  55. test: /\.m?js$/,
  56. exclude: /node_modules\/(?!jsesc|crypto-api)/,
  57. type: "javascript/auto",
  58. loader: "babel-loader?compact=false"
  59. },
  60. {
  61. test: /forge.min.js$/,
  62. loader: "imports-loader?jQuery=>null"
  63. },
  64. {
  65. test: /bootstrap-material-design/,
  66. loader: "imports-loader?Popper=popper.js/dist/umd/popper.js"
  67. },
  68. {
  69. test: /\.css$/,
  70. use: projectCSS.extract({
  71. use: [
  72. { loader: "css-loader" },
  73. { loader: "postcss-loader" },
  74. ]
  75. })
  76. },
  77. {
  78. test: /\.scss$/,
  79. use: vendorCSS.extract({
  80. use: [
  81. { loader: "css-loader" },
  82. { loader: "sass-loader" }
  83. ]
  84. })
  85. },
  86. {
  87. test: /\.(ico|eot|ttf|woff|woff2)$/,
  88. loader: "url-loader",
  89. options: {
  90. limit: 10000
  91. }
  92. },
  93. { // First party images are saved as files to be cached
  94. test: /\.(png|jpg|gif|svg)$/,
  95. exclude: /node_modules/,
  96. loader: "file-loader",
  97. options: {
  98. name: "images/[name].[ext]"
  99. }
  100. },
  101. { // Third party images are inlined
  102. test: /\.(png|jpg|gif|svg)$/,
  103. exclude: /web\/static/,
  104. loader: "url-loader",
  105. options: {
  106. limit: 10000
  107. }
  108. },
  109. ]
  110. },
  111. stats: {
  112. children: false,
  113. chunks: false,
  114. modules: false,
  115. entrypoints: false,
  116. warningsFilter: [
  117. /source-map/,
  118. /dependency is an expression/,
  119. /export 'default'/
  120. ],
  121. },
  122. node: {
  123. fs: "empty"
  124. },
  125. performance: {
  126. hints: false
  127. }
  128. };