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: ['ts-loader', 'angular2-template-loader'],
exclude: /node_modules/
},
{
test: /\.(html|css)$/,
loader: 'raw-loader'
},
]
},
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([
{ 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' },
{ from: '../gnuboat/common/icon/processing.svg', to: 'resources' },
{ from: '../gnuboat/common/icon/log-excluded.svg', to: 'resources' },
{ from: '../gnuboat/common/icon/log-deployed.svg', to: 'resources' },
{ from: '../gnuboat/common/icon/log-queued.svg', to: 'resources' },
{ from: '../gnuboat/common/icon/log-undefined.svg', to: 'resources' }
])
],
optimization: {
splitChunks: {
chunks: 'all',
},
runtimeChunk: true
},
devServer: {
historyApiFallback: true
}
};