webpack.config.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. const rules = {
  8. sourceMap: {
  9. enforce: 'pre',
  10. test: /\.js$/,
  11. loader: 'source-map-loader',
  12. },
  13. js: {
  14. test: /\.js$/,
  15. loader: 'babel-loader',
  16. exclude: /(node_modules)/,
  17. options: {
  18. presets: [
  19. 'es2015',
  20. 'stage-0',
  21. ],
  22. passPerPreset: true,
  23. },
  24. },
  25. styles: {
  26. test: /\.css$/,
  27. use: [
  28. 'style-loader',
  29. {
  30. loader: 'css-loader',
  31. options: {
  32. importLoaders: 1
  33. }
  34. },
  35. {
  36. loader: 'postcss-loader',
  37. options: {
  38. plugins: function () {
  39. return [
  40. require('postcss-cssnext')
  41. ];
  42. }
  43. }
  44. }
  45. ]
  46. }
  47. }
  48. module.exports = {
  49. entry: "./qunit/index.js",
  50. output: {
  51. path: __dirname,
  52. filename: "./qunit.js"
  53. },
  54. externals: {
  55. "qunitjs": "QUnit"
  56. },
  57. module: {
  58. rules: [
  59. rules.sourceMap,
  60. rules.js,
  61. rules.styles
  62. ]
  63. },
  64. resolve: {
  65. alias: {
  66. // "../js/dependencyLibs/inputmask.dependencyLib": "../js/dependencyLibs/inputmask.dependencyLib.jquery",
  67. // "./dependencyLibs/inputmask.dependencyLib": "./dependencyLibs/inputmask.dependencyLib.jquery"
  68. }
  69. },
  70. plugins: [
  71. new webpack.SourceMapDevToolPlugin({
  72. // file and reference
  73. filename: '[file].map',
  74. // sources naming
  75. moduleFilenameTemplate: '[absolute-resource-path]',
  76. fallbackModuleFilenameTemplate: '[absolute-resource-path]',
  77. }),
  78. new webpack.LoaderOptionsPlugin({
  79. debug: true
  80. })
  81. ],
  82. bail: true,
  83. // devServer: {
  84. // publicPath: '/',
  85. // stats: {
  86. // colors: true
  87. // },
  88. // host: '0.0.0.0',
  89. // inline: true,
  90. // port: '8080',
  91. // quiet: false,
  92. // noInfo: false,
  93. // },
  94. };