webpack.common.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Password Management Servlets (PWM)
  3. * http://www.pwm-project.org
  4. *
  5. * Copyright (c) 2006-2009 Novell, Inc.
  6. * Copyright (c) 2009-2017 The PWM Project
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. var HtmlWebpackPlugin = require('html-webpack-plugin');
  23. var autoPrefixer = require('autoprefixer');
  24. var path = require('path');
  25. var webpack = require('webpack');
  26. var outDir = path.resolve(__dirname, 'dist');
  27. module.exports = {
  28. devServer: {
  29. contentBase: outDir,
  30. outputPath: outDir,
  31. port: 4000,
  32. historyApiFallback: true
  33. },
  34. // Externals copied to /dist via CopyWebpackPlugin
  35. externals:
  36. {
  37. 'angular': true,
  38. // Wrapped in window because of hyphens
  39. 'angular-ui-router': 'window["angular-ui-router"]',
  40. 'angular-translate': 'window["angular-translate"]'
  41. },
  42. module: {
  43. preLoaders: [
  44. {
  45. test: /\.ts$/,
  46. loader: 'tslint'
  47. }
  48. ],
  49. loaders: [
  50. {
  51. test: /\.ts$/,
  52. loader: 'ts',
  53. exclude: /node_modules/
  54. },
  55. {
  56. test: /index\.html$/,
  57. loader: 'html',
  58. exclude: /node_modules/
  59. },
  60. {
  61. test: /\.html$/,
  62. loader: 'ngtemplate?relativeTo=' + (path.resolve(__dirname, './src')) + '/!html',
  63. exclude: /index\.html$/
  64. },
  65. {
  66. test: /\.scss$/,
  67. loaders: [ 'style', 'css', 'sass', 'postcss' ]
  68. },
  69. {
  70. test: /\.json/,
  71. loaders: [ 'json' ]
  72. },
  73. {
  74. test: /\.(png|jpg|jpeg|gif|svg)$/,
  75. loaders: [ 'url?limit=25000' ]
  76. }
  77. ]
  78. },
  79. // [name] is replaced by entry point name
  80. output: {
  81. filename: '[name].js',
  82. path: outDir
  83. },
  84. plugins: [
  85. new HtmlWebpackPlugin({
  86. chunks: ['peoplesearch.ng'],
  87. filename: 'peoplesearch.html',
  88. template: 'index.html',
  89. // title: 'PeopleSearch Development',
  90. inject: 'body'
  91. }),
  92. new HtmlWebpackPlugin({
  93. chunks: ['helpdesk.ng'],
  94. filename: 'helpdesk.html',
  95. template: 'index.html',
  96. // title: 'PeopleSearch Development',
  97. inject: 'body'
  98. })
  99. ],
  100. postcss: function() {
  101. return [
  102. autoPrefixer({
  103. browsers: ['last 2 versions']
  104. })
  105. ];
  106. },
  107. resolve: {
  108. extensions: [ '', '.ts', '.js', '.json' ],
  109. modulesDirectories: ['./src', './vendor', 'node_modules']
  110. }
  111. };