const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const path = require('path'); const CopyPlugin = require('copy-webpack-plugin'); module.exports = { entry: './src/main.ts', module: { rules: [ { test: /\.ts$/, use: ['angular2-template-loader'], type: 'asset', exclude: /node_modules/, }, { test: /\.(html|css)$/, type: 'asset', }, ] }, resolve: { extensions: ['.ts', '.js'], alias: { '@': path.resolve(__dirname, 'src/app/'), } }, plugins: [ new HtmlWebpackPlugin({ template: './src/index.html', filename: 'index.html', inject: 'body' }), new webpack.DefinePlugin({ // global app config object config: JSON.stringify({ apiUrl: 'http://localhost:4000' }) }), new CopyPlugin({ patterns: [ { from: 'src/css', to: 'css' }, { from: '../gnuboat/common/css', to: 'css' }, { from: '../gnuboat/common/js', to: 'js' }, { from: '../gnuboat/common/lib', to: 'lib' }, { from: '../gnuboat/common/resources', to: 'resources' }, { from: '../gnuboat/common/icon/gnuboat-256-256-transparent.png', to: 'resources' }, { from: '../gnuboat/common/icon/gnuboat-device.svg', to: 'resources' }, { from: '../gnuboat/common/icon/gnuboat-gauge.svg', to: 'resources' }, { from: '../gnuboat/common/icon/gnuboat-logfile.svg', to: 'resources' }, { from: '../gnuboat/common/icon/gnuboat-water.svg', to: 'resources' }, ] }) ], optimization: { splitChunks: { chunks: 'all', }, runtimeChunk: true }, devServer: { historyApiFallback: true, compress: false, port: 8081 } };