siwe-oidc/js/ui/webpack.config.js
Simon Bihel 0287a60296
Improve UI (#3)
Co-authored-by: Gregório Granado Magalhães <greg.magalhaes@gmail.com>
2021-12-17 15:02:07 +00:00

104 lines
2.2 KiB
JavaScript

const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const sveltePreprocess = require('svelte-preprocess');
const webpack = require('webpack');
const mode = process.env.NODE_ENV || 'development';
const prod = mode === 'production';
module.exports = {
entry: {
'build/bundle': ['./src/main.ts']
},
resolve: {
alias: {
svelte: path.dirname(require.resolve('svelte/package.json'))
},
extensions: ['.mjs', '.js', '.ts', '.svelte'],
mainFields: ['svelte', 'browser', 'module', 'main'],
fallback: {
assert: require.resolve("assert"),
buffer: require.resolve('buffer/'),
crypto: require.resolve('crypto-browserify'),
fs: false,
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
os: require.resolve('os-browserify/browser'),
path: false,
process: require.resolve('process/browser'),
stream: require.resolve('stream-browserify'),
// util: false,
}
},
output: {
path: path.join(__dirname, '../../static'),
filename: '[name].js',
chunkFilename: '[name].[id].js'
},
module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.svelte$/,
use: {
loader: 'svelte-loader',
options: {
compilerOptions: {
dev: !prod
},
emitCss: prod,
hotReload: !prod,
preprocess: sveltePreprocess({
sourceMap: !prod,
postcss: true,
}),
}
}
},
{
test: /\.svg$/,
use: [
{
loader: 'svg-url-loader',
options: {
limit: 10000,
},
},
],
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader'
]
},
{
// required to prevent errors from Svelte on Webpack 5+
test: /node_modules\/svelte\/.*\.mjs$/,
resolve: {
fullySpecified: false
}
}
]
},
mode,
plugins: [
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
process: path.resolve(path.join(__dirname, "node_modules/process/browser")),
}),
new MiniCssExtractPlugin({
filename: '[name].css'
}),
],
devtool: prod ? false : 'source-map',
devServer: {
hot: true
}
};