webpack.config.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. 'use strict';
  2. let webpack = require('webpack');
  3. let path = require('path');
  4. function _path(p) {
  5. return path.join(__dirname, p);
  6. }
  7. module.exports = {
  8. entry: "./app.js",
  9. output: {
  10. path: __dirname,
  11. filename: "build/bundle.js"
  12. },
  13. module: {
  14. rules: [
  15. {
  16. enforce: 'pre',
  17. test: /\.js$/,
  18. loader: 'source-map-loader',
  19. },
  20. {
  21. test: /\.js$/,
  22. loader: 'babel-loader',
  23. exclude: /(node_modules)/,
  24. options: {
  25. presets: [
  26. 'es2015',
  27. 'stage-0',
  28. ],
  29. passPerPreset: true,
  30. },
  31. },
  32. {
  33. test: /\.css$/,
  34. use: [
  35. 'style-loader',
  36. {
  37. loader: 'css-loader',
  38. options: {
  39. importLoaders: 1
  40. }
  41. },
  42. {
  43. loader: 'postcss-loader',
  44. options: {
  45. plugins: function () {
  46. return [
  47. require('postcss-cssnext')
  48. ];
  49. }
  50. }
  51. }
  52. ]
  53. }
  54. ]
  55. },
  56. resolve: {
  57. alias: {}
  58. },
  59. plugins: [
  60. new webpack.SourceMapDevToolPlugin({
  61. // file and reference
  62. filename: '[file].map',
  63. // sources naming
  64. moduleFilenameTemplate: '[absolute-resource-path]',
  65. fallbackModuleFilenameTemplate: '[absolute-resource-path]',
  66. }),
  67. new webpack.LoaderOptionsPlugin({
  68. debug: true
  69. })
  70. ],
  71. bail: true,
  72. devServer: {
  73. publicPath: '/',
  74. stats: {
  75. colors: true
  76. },
  77. host: '0.0.0.0',
  78. inline: true,
  79. port: '8080',
  80. quiet: false,
  81. noInfo: false,
  82. },
  83. };