cockpit-tailscale/webpack.config.js

129 lines
3.8 KiB
JavaScript
Raw Normal View History

2023-06-21 22:40:02 -06:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2023-06-17 09:45:41 -06:00
const path = require('path');
2023-06-21 22:40:02 -06:00
const { stylePaths } = require('./stylePaths');
2023-06-17 09:45:41 -06:00
module.exports = {
devtool: "source-map",
entry: './src/index.tsx',
module: {
rules: [
{
2023-06-21 22:40:02 -06:00
test: /\.(ts|tsx|jsx)?$/,
use: [
{
loader: 'ts-loader',
2023-06-22 00:10:13 -06:00
options: {
2023-06-21 22:40:02 -06:00
transpileOnly: true,
experimentalWatchApi: true,
},
}
]
2023-06-17 09:45:41 -06:00
},
2023-06-22 00:10:13 -06:00
{
test: /\.s[ac]ss$/i,
use: [
"css-loader",
"sass-loader",
],
},
2023-06-21 22:40:02 -06:00
{
test: /\.css$/,
include: [...stylePaths],
use: [MiniCssExtractPlugin.loader, 'css-loader'],
2023-06-22 00:10:13 -06:00
}, {
test: /\.(svg|ttf|eot|woff|woff2)$/,
// only process modules with this loader
// if they live under a 'fonts' or 'pficon' directory
include: [
path.resolve(__dirname, 'node_modules/patternfly/dist/fonts'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/dist/styles/assets/fonts'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/dist/styles/assets/pficon'),
path.resolve(__dirname, 'node_modules/@patternfly/patternfly/assets/fonts'),
path.resolve(__dirname, 'node_modules/@patternfly/patternfly/assets/pficon'),
],
use: {
loader: 'file-loader',
options: {
// Limit at 50k. larger files emited into separate files
limit: 5000,
outputPath: 'fonts',
name: '[name].[ext]',
},
},
},
{
test: /\.svg$/,
include: (input) => input.indexOf('background-filter.svg') > 1,
use: [
{
loader: 'url-loader',
2023-06-21 22:40:02 -06:00
options: {
limit: 5000,
2023-06-22 00:10:13 -06:00
outputPath: 'svgs',
2023-06-21 22:40:02 -06:00
name: '[name].[ext]',
},
},
2023-06-22 00:10:13 -06:00
],
},
{
test: /\.(jpg|jpeg|png|gif)$/i,
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules/patternfly'),
path.resolve(__dirname, 'node_modules/@patternfly/patternfly/assets/images'),
path.resolve(__dirname, 'node_modules/@patternfly/react-styles/css/assets/images'),
path.resolve(__dirname, 'node_modules/@patternfly/react-core/dist/styles/assets/images'),
path.resolve(
__dirname,
'node_modules/@patternfly/react-core/node_modules/@patternfly/react-styles/css/assets/images'
),
path.resolve(
__dirname,
'node_modules/@patternfly/react-table/node_modules/@patternfly/react-styles/css/assets/images'
),
path.resolve(
__dirname,
'node_modules/@patternfly/react-inline-edit-extension/node_modules/@patternfly/react-styles/css/assets/images'
),
],
use: [
{
loader: 'url-loader',
options: {
limit: 5000,
outputPath: 'images',
name: '[name].[ext]',
2023-06-21 22:40:02 -06:00
},
2023-06-22 00:10:13 -06:00
},
],
},
2023-06-17 09:45:41 -06:00
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
2023-06-21 23:14:03 -06:00
modules: ["node_modules", 'pkg/lib'],
alias: { 'font-awesome': 'font-awesome-sass/assets/stylesheets' },
},
resolveLoader: {
modules: ["node_modules", 'pkg/lib'],
2023-06-17 09:45:41 -06:00
},
2023-06-21 22:40:02 -06:00
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'src', 'index.html'),
}),
new MiniCssExtractPlugin({
filename: 'bundle.css',
}),
],
2023-06-17 09:45:41 -06:00
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
devServer: {
static: path.join(__dirname, "dist"),
compress: true,
port: 4000,
},
};