webpack.config.js 3.9 KB

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