gengitkan/client/webpack.config.js

70 lines
1.6 KiB
JavaScript
Raw Normal View History

2019-11-28 11:50:51 +01:00
const path = require('path');
// Plugins
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
2019-12-13 14:21:20 +01:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackCleanupPlugin = require('webpack-cleanup-plugin');
2019-11-28 11:50:51 +01:00
const env = process.env;
module.exports = {
mode: `${env.NODE_ENV ? env.NODE_ENV : 'production'}`,
2020-04-30 13:02:56 +02:00
entry: './src/index.tsx',
devtool: 'inline-source-map',
2019-11-28 11:50:51 +01:00
output: {
path: path.join(__dirname, 'dist')
},
2019-11-28 14:12:48 +01:00
resolve: {
2020-04-30 13:02:56 +02:00
extensions: [".ts", ".tsx", ".js", ".jsx"]
2019-11-28 14:12:48 +01:00
},
2019-11-28 11:50:51 +01:00
module: {
rules: [{
test: /\.s(a|c)ss$/,
2019-11-28 11:50:51 +01:00
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {}
},
{
loader: "resolve-url-loader",
options: {}
},
{
loader: "sass-loader",
options: {
sourceMap: true,
sourceMapContents: false
}
}
]
},{
2019-12-05 16:23:20 +01:00
test: /\.(woff(2)?|ttf|eot|svg|png)(\?v=\d+\.\d+\.\d+)?$/,
2019-11-28 11:50:51 +01:00
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
2019-12-05 16:15:33 +01:00
outputPath: '/resources/'
2019-11-28 11:50:51 +01:00
}
}]
},{
2020-04-30 13:02:56 +02:00
test: /\.(t|j)sx?$/,
2019-11-28 11:50:51 +01:00
exclude: /node_modules/,
2020-04-30 13:02:56 +02:00
loaders: ['ts-loader']
2019-11-28 11:50:51 +01:00
}]
},
plugins: [
new MiniCssExtractPlugin({
filename: "css/[name].css",
chunkFilename: "css/[id].css"
2019-12-13 14:21:20 +01:00
}),
new HtmlWebpackPlugin({
template: './src/index.html',
inject: false,
favicon: "./src/resources/favicon.png"
}),
new WebpackCleanupPlugin({
exclude: ['resources/logo.svg']
2019-11-28 11:50:51 +01:00
})
]
}