You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

webpack.config.dev.js 4.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2016 SonarSource SA
  4. * mailto:contact AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. var webpack = require('webpack');
  21. var HtmlWebpackPlugin = require('html-webpack-plugin');
  22. var ExtractTextPlugin = require('extract-text-webpack-plugin');
  23. var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
  24. var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
  25. var WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
  26. var paths = require('../paths');
  27. var config = require('./webpack.config.base');
  28. var getClientEnvironment = require('../env');
  29. var publicPath = '';
  30. var webContext = '';
  31. var env = getClientEnvironment();
  32. // This makes the bundle appear split into separate modules in the devtools.
  33. // We don't use source maps here because they can be confusing:
  34. // https://github.com/facebookincubator/create-react-app/issues/343#issuecomment-237241875
  35. // You may want 'cheap-module-source-map' instead if you prefer source maps.
  36. config.devtool = 'eval';
  37. // Include an alternative client for WebpackDevServer. A client's job is to
  38. // connect to WebpackDevServer by a socket and get notified about changes.
  39. // When you save a file, the client will either apply hot updates (in case
  40. // of CSS changes), or refresh the page (in case of JS changes). When you
  41. // make a syntax error, this client will display a syntax error overlay.
  42. // Note: instead of the default WebpackDevServer client, we use a custom one
  43. // to bring better experience for Create React App users. You can replace
  44. // the line below with these two lines if you prefer the stock client:
  45. // require.resolve('webpack-dev-server/client') + '?/',
  46. // require.resolve('webpack/hot/dev-server'),
  47. config.entry.vendor.unshift(require.resolve('react-dev-utils/webpackHotDevClient'));
  48. // Add /* filename */ comments to generated require()s in the output.
  49. config.output.pathinfo = true;
  50. // This is the URL that app is served from.
  51. config.output.publicPath = publicPath;
  52. config.output.filename = 'js/[name].js';
  53. config.output.chunkFilename = 'js/[name].chunk.js';
  54. config.plugins = [
  55. new webpack.optimize.CommonsChunkPlugin('vendor', 'js/vendor.js'),
  56. new ExtractTextPlugin('css/sonar.css', { allChunks: true }),
  57. // Makes the web context available as %WEB_CONTEXT% in index.html, e.g.:
  58. // <link rel="shortcut icon" href="%WEB_CONTEXT%/favicon.ico">
  59. // In development, this will be an empty string.
  60. new InterpolateHtmlPlugin({
  61. WEB_CONTEXT: webContext
  62. }),
  63. // Generates an `index.html` file with the <script> injected.
  64. new HtmlWebpackPlugin({
  65. inject: false,
  66. template: paths.appHtml,
  67. }),
  68. // Makes some environment variables available to the JS code, for example:
  69. // if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
  70. new webpack.DefinePlugin(env),
  71. // This is necessary to emit hot updates (currently CSS only):
  72. new webpack.HotModuleReplacementPlugin(),
  73. // Watcher doesn't work well if you mistype casing in a path so we use
  74. // a plugin that prints an error when you attempt to do this.
  75. // See https://github.com/facebookincubator/create-react-app/issues/240
  76. new CaseSensitivePathsPlugin(),
  77. // If you require a missing module and then `npm install` it, you still have
  78. // to restart the development server for Webpack to discover it. This plugin
  79. // makes the discovery automatic so you don't have to restart.
  80. // See https://github.com/facebookincubator/create-react-app/issues/186
  81. new WatchMissingNodeModulesPlugin(paths.appNodeModules)
  82. ];
  83. module.exports = config;