webpack.config.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. var webpack = require("webpack"),
  2. UglifyJsPlugin = require("uglifyjs-webpack-plugin");
  3. function createBanner() {
  4. return "[name]\n" +
  5. "<%= pkg.homepage %>\n" +
  6. "Copyright (c) 2010 - <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>\n" +
  7. "Licensed under the <%= pkg.license %> license\n" +
  8. "Version: <%= pkg.version %>";
  9. }
  10. var rules = {
  11. // sourceMap: {
  12. // enforce: 'pre',
  13. // test: /\.js$/,
  14. // loader: 'source-map-loader',
  15. // },
  16. js: {
  17. test: /\.js$/,
  18. loader: "babel-loader",
  19. exclude: /(node_modules)/,
  20. options: {
  21. presets: [
  22. ["@babel/preset-env"]
  23. ],
  24. passPerPreset: true,
  25. },
  26. },
  27. // ts: {
  28. // test: /\.tsx?$/,
  29. // loader: 'awesome-typescript-loader',
  30. // exclude: /(node_modules)/
  31. // },
  32. styles: {
  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. module.exports = {
  56. entry: {
  57. "dist/inputmask": "./bundle.js",
  58. "dist/inputmask.min": "./bundle.js",
  59. "qunit/qunit": "./qunit/index.js"
  60. },
  61. output: {
  62. path: __dirname,
  63. filename: "[name].js",
  64. libraryTarget: "umd"
  65. },
  66. externals: {
  67. "jquery": {
  68. commonjs: "jquery",
  69. commonjs2: "jquery",
  70. amd: "jquery",
  71. root: "jQuery"
  72. },
  73. "jqlite": "jqlite",
  74. "qunit": "QUnit"
  75. },
  76. optimization: {
  77. minimize: false,
  78. minimizer: [new UglifyJsPlugin({
  79. include: /\.min\.js$/,
  80. sourceMap: false,
  81. uglifyOptions: {
  82. warnings: "verbose",
  83. mangle: false,
  84. compress: {
  85. keep_fnames: true,
  86. unused: false,
  87. typeofs: false,
  88. dead_code: false,
  89. collapse_vars: false
  90. },
  91. output: {
  92. ascii_only: true,
  93. beautify: false,
  94. comments: /^!/
  95. }
  96. },
  97. extractComments: false
  98. }), new UglifyJsPlugin({
  99. exclude: /\.min\.js$/,
  100. sourceMap: true,
  101. uglifyOptions: {
  102. warnings: "verbose",
  103. mangle: false,
  104. compress: {
  105. keep_fnames: true,
  106. unused: false,
  107. typeofs: false,
  108. dead_code: false,
  109. collapse_vars: false
  110. },
  111. output: {
  112. ascii_only: true,
  113. beautify: true,
  114. comments: /^!/
  115. }
  116. },
  117. extractComments: false
  118. })]
  119. },
  120. module: {
  121. rules: [
  122. // rules.sourceMap,
  123. rules.js,
  124. // rules.ts,
  125. rules.styles
  126. ]
  127. },
  128. resolve: {
  129. alias: {
  130. // "./dependencyLibs/inputmask.dependencyLib": "./dependencyLibs/inputmask.dependencyLib.jquery"
  131. // "./dependencyLibs/inputmask.dependencyLib": "./dependencyLibs/inputmask.dependencyLib.jqlite"
  132. }
  133. },
  134. devtool: "source-map",
  135. plugins: [
  136. new webpack.BannerPlugin({
  137. banner: createBanner(),
  138. entryOnly: true
  139. })
  140. ],
  141. bail: true,
  142. mode: "none"
  143. // devServer: {
  144. // publicPath: '/',
  145. // stats: {
  146. // colors: true
  147. // },
  148. // host: '0.0.0.0',
  149. // inline: true,
  150. // port: '8080',
  151. // quiet: false,
  152. // noInfo: false,
  153. // },
  154. };