2020-06-15 18:10:06 +02:00
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
// Plugins
|
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
2020-06-18 09:48:45 +02:00
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
2020-06-15 18:10:06 +02:00
|
|
|
|
|
|
|
const env = process.env;
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
mode: `${env.NODE_ENV ? env.NODE_ENV : 'production'}`,
|
|
|
|
entry: './src/index.tsx',
|
|
|
|
devtool: 'inline-source-map',
|
|
|
|
output: {
|
2020-06-18 09:48:45 +02:00
|
|
|
filename: '[name].[contenthash].js',
|
2020-06-15 18:10:06 +02:00
|
|
|
path: path.join(__dirname, 'dist')
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: [".ts", ".tsx", ".js", ".jsx"]
|
|
|
|
},
|
|
|
|
devServer: {
|
|
|
|
contentBase: path.join(__dirname, 'dist'),
|
|
|
|
compress: true,
|
2020-06-18 09:48:45 +02:00
|
|
|
port: 8081,
|
|
|
|
historyApiFallback: true,
|
|
|
|
writeToDisk: true,
|
2020-06-15 18:10:06 +02:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [{
|
|
|
|
test: /\.s(a|c)ss$/,
|
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
{
|
|
|
|
loader: "css-loader",
|
|
|
|
options: {}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: "resolve-url-loader",
|
|
|
|
options: {}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: "sass-loader",
|
|
|
|
options: {
|
|
|
|
sourceMap: true,
|
|
|
|
sourceMapContents: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},{
|
|
|
|
test: /\.(woff(2)?|ttf|eot|svg|png)(\?v=\d+\.\d+\.\d+)?$/,
|
|
|
|
use: [{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2020-06-18 09:48:45 +02:00
|
|
|
name: '[name].[contenthash].[ext]',
|
2020-06-15 18:10:06 +02:00
|
|
|
outputPath: '/resources/'
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
},{
|
|
|
|
test: /\.(t|j)sx?$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
loaders: ['ts-loader']
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
plugins: [
|
2020-06-18 09:48:45 +02:00
|
|
|
new CleanWebpackPlugin(),
|
2020-06-15 18:10:06 +02:00
|
|
|
new MiniCssExtractPlugin({
|
2020-06-18 09:48:45 +02:00
|
|
|
filename: "css/[name].[contenthash].css",
|
2020-06-15 18:10:06 +02:00
|
|
|
chunkFilename: "css/[id].css"
|
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: './src/index.html',
|
|
|
|
inject: false,
|
2020-06-18 09:48:45 +02:00
|
|
|
favicon: "./src/resources/favicon.png",
|
2020-06-15 18:10:06 +02:00
|
|
|
}),
|
|
|
|
]
|
|
|
|
}
|