webpack.config.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. moment: "moment-timezone"
  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: /\.js$/,
  53. exclude: /node_modules/,
  54. loader: "babel-loader?compact=false"
  55. },
  56. {
  57. test: /\.css$/,
  58. use: ExtractTextPlugin.extract({
  59. use: [
  60. { loader: "css-loader?minimize" },
  61. { loader: "postcss-loader" },
  62. ]
  63. })
  64. },
  65. {
  66. test: /\.less$/,
  67. use: ExtractTextPlugin.extract({
  68. use: [
  69. { loader: "css-loader?minimize" },
  70. { loader: "postcss-loader" },
  71. { loader: "less-loader" }
  72. ]
  73. })
  74. },
  75. {
  76. test: /\.(ico|eot|ttf|woff|woff2)$/,
  77. loader: "url-loader",
  78. options: {
  79. limit: 10000
  80. }
  81. },
  82. { // First party images are saved as files to be cached
  83. test: /\.(png|jpg|gif|svg)$/,
  84. exclude: /node_modules/,
  85. loader: "file-loader",
  86. options: {
  87. name: "images/[name].[ext]"
  88. }
  89. },
  90. { // Third party images are inlined
  91. test: /\.(png|jpg|gif|svg)$/,
  92. exclude: /web\/static/,
  93. loader: "url-loader",
  94. options: {
  95. limit: 10000
  96. }
  97. },
  98. ]
  99. },
  100. stats: {
  101. children: false,
  102. warningsFilter: /source-map/
  103. }
  104. };