1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 17:17:31 +00:00
transmission/web/webpack.config.js
Charles Kerr ebd1a0b7bf
deps: update web client build deps (#3095)
* deps: change web build-dep from node-sass to sass

https://sass-lang.com/blog/libsass-is-deprecated and dart sass is the
recommended replacement.

* deps: yarn upgrade-interactive

* deps: update babel dep to 7.17

* deps: update eslint

* deps: update prettier

* deps: update svgo

* deps: update webpack to 5.72.1

* deps: update webpack-bundle-analyzer to 4.5.0

* deps: update webpack-cli to 4.9.2

* deps: update webpack-dev-server from 3.11.3 to 4.9.0

* deps: replace svgo, svgo-loader, url-loader with webpack asset/inline

* chore: rename "style" dir as "assets"

* deps: update stylelint from 13.13.1 to 14.8.2

* deps: bump terser-webpack-plugin from 5.1.4 to 5.3.1

* deps: bump css-loader from 5.2.7 to 6.7.1

* deps: bump css-minimizer-webpack-plugin from 3.0.2 to 3.4.1

* deps: bump mini-css-extract-plugin from 1.6.2 to 2.6.0
2022-05-15 20:49:25 -05:00

82 lines
1.8 KiB
JavaScript

const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const webpack = require('webpack');
const mode = process.env.WEBPACK_MODE || 'production';
const devPort = process.env.DEV_PORT || 9000;
const rpcUrl = process.env.RPC_URL || 'http://localhost:9091/transmission/rpc';
const config = {
devtool: 'source-map',
entry: './src/main.js',
mode,
module: {
rules: [
{
test: /\.s(a|c)ss$/,
use: [
'style-loader', // create 'style' nodes from JS strings
'css-loader', // translate css into commonjs
'sass-loader', // compile sass into css
],
},
{
test: /\.css$/i,
use: [ 'style-loader', 'css-loader' ],
},
{
exclude: /(node_modules)/,
include: /(assets)\/(img)/,
test: /\.(jpe?g|png|gif|svg|webp)$/,
type: 'asset/inline',
},
],
},
optimization: {
minimizer: [
new TerserPlugin(),
new CssMinimizerPlugin(),
],
},
output: {
filename: 'transmission-app.js' ,
path: path.resolve(__dirname, 'public_html'),
sourceMapFilename: 'transmission-app.js.map'
},
plugins: [
new MiniCssExtractPlugin({
chunkFilename: '[id].css',
filename: '[name].css'
}),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
],
resolve: {
extensions: ['.js', '.scss']
},
};
if (mode === 'development') {
config.devServer = {
compress: true,
historyApiFallback: {
rewrites: [
{ from: '/transmission/web', to: '/' },
]
},
hot: true,
port: devPort,
proxy: {
'/rpc': rpcUrl
},
static: './public_html'
};
}
module.exports = config;