123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- const path = require('path');
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- const CopyWebpackPlugin = require('copy-webpack-plugin');
- const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
- const webpackMerge = require('webpack-merge');
- const webpack = require('webpack');
- const autoPrefixer = require('autoprefixer');
- const outDir = path.resolve(__dirname, 'dist');
- const srcDir = path.resolve(__dirname, 'src');
- module.exports = function (env, argv) {
- const isProductionMode = (argv["mode"] === "production");
- const commonConfig = {
- devtool: 'source-map',
- entry: {
- 'changepassword.ng': './src/modules/changepassword/changepassword.module',
- 'configeditor.ng': './src/modules/configeditor/configeditor.module'
- // (see production and development specific sections below for more entries)
- },
- output: {
- filename: "[name].js",
- path: outDir
- },
- resolve: {
- extensions: [".ts", ".js"]
- },
- module: {
- rules: [
- {
- test: /.ts$/,
- loader: "ts-loader"
- },
- {
- test: /\.ts$/,
- enforce: 'pre',
- loader: 'tslint-loader'
- },
- {
- test: /index-dev\.html$/,
- loader: 'html-loader',
- exclude: /node_modules/
- },
- {
- test: /\.html$/,
- loader: 'ngtemplate-loader!html-loader',
- exclude: /index-dev\.html$/
- },
- {
- test: /\.(scss)$/,
- loaders: [ 'style-loader', 'css-loader', 'sass-loader', {
- loader: 'postcss-loader',
- options: {
- plugins: function () {
- return [autoPrefixer('last 2 versions')]
- }
- }
- }]
- },
- {
- test: /\.(png|jpg|jpeg|gif|svg)$/,
- loaders: [ 'url-loader?limit=25000' ]
- },
- {
- test: [
- require.resolve("textangular"),
- require.resolve("textangular/dist/textAngular-sanitize")
- ],
- use: "imports-loader?angular"
- }
- ]
- },
- plugins: [
- new CopyWebpackPlugin([
- { from: 'node_modules/@microfocus/ux-ias/dist/ux-ias.css', to: 'vendor/ux-ias/' },
- { from: 'node_modules/@microfocus/ias-icons/dist/ias-icons.css', to: 'vendor/ux-ias/' },
- { from: 'node_modules/@microfocus/ias-icons/dist/fonts', to: 'vendor/ux-ias/fonts' },
- { from: 'node_modules/textangular/dist/textAngular.css', to: 'vendor/textangular' }
- ])
- ],
- optimization: {
- splitChunks: {
- cacheGroups: {
- vendor: {
- test: /[\\/]node_modules[\\/]/,
- name: "vendor",
- chunks: "all"
- }
- }
- }
- }
- };
- if (isProductionMode) {
- // Production-specific configuration
- return webpackMerge(commonConfig, {
- entry: {
- 'peoplesearch.ng': './src/modules/peoplesearch/main',
- 'helpdesk.ng': './src/modules/helpdesk/main'
- },
- plugins: [
- new UglifyJsPlugin({
- sourceMap: true,
- uglifyOptions: {
- compress: {warnings: false},
- comments: false
- }
- })
- ]
- });
- }
- else {
- // Development-specific configuration
- return webpackMerge(commonConfig, {
- entry: {
- 'peoplesearch.ng': './src/modules/peoplesearch/main.dev',
- 'helpdesk.ng': './src/modules/helpdesk/main.dev'
- },
- plugins: [
- new HtmlWebpackPlugin({
- chunks: ['peoplesearch.ng', 'vendor'],
- chunksSortMode: 'dependency',
- filename: 'peoplesearch.html',
- template: 'src/index-dev.html',
- inject: 'body',
- livereload: true
- }),
- new HtmlWebpackPlugin({
- chunks: ['helpdesk.ng', 'vendor'],
- chunksSortMode: 'dependency',
- filename: 'helpdesk.html',
- template: 'src/index-dev.html',
- inject: 'body',
- livereload: true
- })
- ],
- });
- }
- };
|