| 1 | const webpack = require('webpack');
|
|---|
| 2 | const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|---|
| 3 | const path = require('path');
|
|---|
| 4 | const CopyPlugin = require('copy-webpack-plugin');
|
|---|
| 5 |
|
|---|
| 6 | module.exports = {
|
|---|
| 7 | entry: './src/main.ts',
|
|---|
| 8 | module: {
|
|---|
| 9 | rules: [
|
|---|
| 10 | {
|
|---|
| 11 | test: /\.ts$/,
|
|---|
| 12 | use: ['angular2-template-loader'],
|
|---|
| 13 | type: 'asset',
|
|---|
| 14 | exclude: /node_modules/,
|
|---|
| 15 | },
|
|---|
| 16 | {
|
|---|
| 17 | test: /\.(html|css)$/,
|
|---|
| 18 | type: 'asset',
|
|---|
| 19 | },
|
|---|
| 20 | ]
|
|---|
| 21 | },
|
|---|
| 22 | resolve: {
|
|---|
| 23 | extensions: ['.ts', '.js'],
|
|---|
| 24 | alias: {
|
|---|
| 25 | '@': path.resolve(__dirname, 'src/app/'),
|
|---|
| 26 | }
|
|---|
| 27 | },
|
|---|
| 28 | plugins: [
|
|---|
| 29 | new HtmlWebpackPlugin({
|
|---|
| 30 | template: './src/index.html',
|
|---|
| 31 | filename: 'index.html',
|
|---|
| 32 | inject: 'body'
|
|---|
| 33 | }),
|
|---|
| 34 | new webpack.DefinePlugin({
|
|---|
| 35 | // global app config object
|
|---|
| 36 | config: JSON.stringify({
|
|---|
| 37 | apiUrl: 'http://localhost:4000'
|
|---|
| 38 | })
|
|---|
| 39 | }),
|
|---|
| 40 | new CopyPlugin({
|
|---|
| 41 | patterns: [
|
|---|
| 42 | { from: 'src/css', to: 'css' },
|
|---|
| 43 | { from: '../gnuboat/common/css', to: 'css' },
|
|---|
| 44 | { from: '../gnuboat/common/js', to: 'js' },
|
|---|
| 45 | { from: '../gnuboat/common/lib', to: 'lib' },
|
|---|
| 46 | { from: '../gnuboat/common/resources', to: 'resources' },
|
|---|
| 47 | { from: '../gnuboat/common/icon/gnuboat-256-256-transparent.png', to: 'resources' },
|
|---|
| 48 | { from: '../gnuboat/common/icon/gnuboat-device.svg', to: 'resources' },
|
|---|
| 49 | { from: '../gnuboat/common/icon/gnuboat-gauge.svg', to: 'resources' },
|
|---|
| 50 | { from: '../gnuboat/common/icon/gnuboat-logfile.svg', to: 'resources' },
|
|---|
| 51 | { from: '../gnuboat/common/icon/gnuboat-water.svg', to: 'resources' },
|
|---|
| 52 | ]
|
|---|
| 53 | })
|
|---|
| 54 | ],
|
|---|
| 55 | optimization: {
|
|---|
| 56 | splitChunks: {
|
|---|
| 57 | chunks: 'all',
|
|---|
| 58 | },
|
|---|
| 59 | runtimeChunk: true
|
|---|
| 60 | },
|
|---|
| 61 | devServer: {
|
|---|
| 62 | historyApiFallback: true,
|
|---|
| 63 | compress: false,
|
|---|
| 64 | port: 8081
|
|---|
| 65 | }
|
|---|
| 66 | };
|
|---|