webpack.config.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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: "./bundle.js",
  50. output: {
  51. path: __dirname,
  52. filename: "build/bundle.js"
  53. },
  54. externals: {
  55. "jquery": "jQuery"
  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. //"./js/dependencyLibs/inputmask.dependencyLib": "./js/dependencyLibs/inputmask.dependencyLib.jqlite",
  69. // "./dependencyLibs/inputmask.dependencyLib": "./dependencyLibs/inputmask.dependencyLib.jqlite"
  70. }
  71. },
  72. plugins: [
  73. new webpack.SourceMapDevToolPlugin({
  74. // file and reference
  75. filename: '[file].map',
  76. // sources naming
  77. moduleFilenameTemplate: '[absolute-resource-path]',
  78. fallbackModuleFilenameTemplate: '[absolute-resource-path]',
  79. }),
  80. new webpack.LoaderOptionsPlugin({
  81. debug: true
  82. })
  83. ],
  84. bail: true,
  85. // devServer: {
  86. // publicPath: '/',
  87. // stats: {
  88. // colors: true
  89. // },
  90. // host: '0.0.0.0',
  91. // inline: true,
  92. // port: '8080',
  93. // quiet: false,
  94. // noInfo: false,
  95. // },
  96. };