webpack.local.config.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. const webpack = require('webpack');
  2. const autoprefixer = require('autoprefixer');
  3. const path = require('path');
  4. const HtmlWebpackPlugin = require('html-webpack-plugin');
  5. /**
  6. * This is the Webpack configuration file for local development.
  7. * It contains local-specific configuration which includes:
  8. *
  9. * - Hot reloading configuration
  10. * - The entry points of the application
  11. * - Which loaders to use on what files to properly transpile the source
  12. *
  13. * For more information, see: http://webpack.github.io/docs/configuration.html
  14. */
  15. module.exports = {
  16. // Efficiently evaluate modules with source maps
  17. devtool: 'eval-source-map',
  18. // Set entry points with hot loading
  19. entry: {
  20. app: [
  21. './app/scripts/main',
  22. 'webpack-hot-middleware/client'
  23. ],
  24. 'dev-app': [
  25. './app/scripts/main.dev',
  26. 'webpack-hot-middleware/client'
  27. ],
  28. 'terminal-app': [
  29. './app/scripts/terminal-main',
  30. 'webpack-hot-middleware/client'
  31. ],
  32. vendors: ['@babel/polyfill', 'classnames', 'dagre', 'filesize', 'immutable',
  33. 'moment', 'page', 'react', 'react-dom', 'react-motion', 'react-redux', 'redux',
  34. 'redux-thunk', 'reqwest', 'xterm', 'webpack-hot-middleware/client'
  35. ]
  36. },
  37. // See https://webpack.js.org/concepts/mode/#mode-development.
  38. mode: 'development',
  39. // Used by Webpack Dev Middleware
  40. output: {
  41. filename: '[name].js',
  42. path: path.join(__dirname, 'build'),
  43. publicPath: '',
  44. },
  45. // Necessary plugins for hot load
  46. plugins: [
  47. new webpack.HotModuleReplacementPlugin(),
  48. new webpack.NoEmitOnErrorsPlugin(),
  49. new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
  50. new HtmlWebpackPlugin({
  51. chunks: ['vendors', 'terminal-app'],
  52. filename: 'terminal.html',
  53. template: 'app/html/index.html',
  54. }),
  55. new HtmlWebpackPlugin({
  56. chunks: ['vendors', 'dev-app'],
  57. filename: 'dev.html',
  58. template: 'app/html/index.html',
  59. }),
  60. new HtmlWebpackPlugin({
  61. chunks: ['vendors', 'app'],
  62. filename: 'index.html',
  63. template: 'app/html/index.html',
  64. }),
  65. ],
  66. // Transform source code using Babel and React Hot Loader
  67. module: {
  68. // Webpack is opionated about how pkgs should be laid out:
  69. // https://github.com/webpack/webpack/issues/1617
  70. noParse: [/xterm\/(.*).map$/, /xterm\/dist\/xterm\.js/],
  71. rules: [
  72. {
  73. test: /\.js$/,
  74. exclude: /node_modules|vendor/,
  75. loaders: [
  76. // 'eslint-loader',
  77. 'stylelint-custom-processor-loader',
  78. ],
  79. enforce: 'pre'
  80. },
  81. {
  82. test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
  83. loader: 'url-loader',
  84. options: {
  85. limit: 10000,
  86. minetype: 'application/font-woff',
  87. }
  88. },
  89. {
  90. test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
  91. loader: 'file-loader'
  92. },
  93. {
  94. test: /\.(ico)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
  95. loader: 'file-loader',
  96. options: {
  97. // Handle favicon.ico separately as it needs to preserve its name to be applied correctly.
  98. // See https://github.com/coryhouse/react-slingshot/issues/128#issuecomment-216363426.
  99. name: '[name].[ext]',
  100. },
  101. },
  102. {
  103. test: /\.jsx?$/,
  104. exclude: /node_modules|vendor/,
  105. use: [
  106. { loader: 'babel-loader', options: { cacheDirectory: true } },
  107. ]
  108. },
  109. {
  110. test: /\.(css|less)$/,
  111. use: [
  112. { loader: 'style-loader' },
  113. { loader: 'css-loader' },
  114. { loader: 'less-loader' },
  115. {
  116. loader: 'postcss-loader',
  117. options: {
  118. plugins: [
  119. autoprefixer({
  120. browsers: ['last 2 versions']
  121. })
  122. ]
  123. }
  124. },
  125. ],
  126. }
  127. ]
  128. },
  129. // Automatically transform files with these extensions
  130. resolve: {
  131. extensions: ['.js', '.jsx']
  132. },
  133. };