IMPR: Add ts-loader

This commit is contained in:
Tony Air 2021-09-12 22:49:47 +02:00
parent 92e8cfa5b5
commit ff5f84f500
3 changed files with 166 additions and 165 deletions

View File

@ -172,6 +172,8 @@
"terser-webpack-plugin": "^5.2.3", "terser-webpack-plugin": "^5.2.3",
"ts-invariant": "^0.9.1", "ts-invariant": "^0.9.1",
"tslib": "^2.3.1", "tslib": "^2.3.1",
"ts-loader": "^9.2.5",
"typescript": "^4.4.3",
"url": "^0.11.0", "url": "^0.11.0",
"url-loader": "^4.1.1", "url-loader": "^4.1.1",
"webpack": "^5.52.0", "webpack": "^5.52.0",

View File

@ -6,10 +6,9 @@ const conf = common.configuration;
const webpack = require('webpack'); const webpack = require('webpack');
const { const {
merge merge,
} = require('webpack-merge'); } = require('webpack-merge');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
@ -204,7 +203,7 @@ const cfg = merge(common.webpack, {
'default', 'default',
{ {
discardComments: { discardComments: {
removeAll: true removeAll: true,
}, },
zindex: true, zindex: true,
cssDeclarationSorter: true, cssDeclarationSorter: true,
@ -221,7 +220,7 @@ const cfg = merge(common.webpack, {
minify: [ minify: [
CssMinimizerPlugin.cssnanoMinify, CssMinimizerPlugin.cssnanoMinify,
//CssMinimizerPlugin.cleanCssMinify, //CssMinimizerPlugin.cleanCssMinify,
] ],
}), }),
], ],
}, },
@ -233,7 +232,7 @@ const cfg = merge(common.webpack, {
}, },
module: { module: {
rules: [{ rules: [{ test: /\.tsx?$/, loader: 'ts-loader' }, {
test: /\.jsx?$/, test: /\.jsx?$/,
//exclude: /node_modules/, //exclude: /node_modules/,
use: { use: {
@ -250,7 +249,7 @@ const cfg = merge(common.webpack, {
}, },
], //Preset used for env setup ], //Preset used for env setup
plugins: [ plugins: [
['@babel/transform-react-jsx'] ['@babel/transform-react-jsx'],
], ],
cacheDirectory: true, cacheDirectory: true,
cacheCompression: true, cacheCompression: true,
@ -280,15 +279,15 @@ const cfg = merge(common.webpack, {
}, },
{ {
test: /fontawesome([^.]+).(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/, test: /fontawesome([^.]+).(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
type: "asset/resource", type: 'asset/resource',
}, },
{ {
test: /\.(ttf|otf|eot|woff(2)?)$/, test: /\.(ttf|otf|eot|woff(2)?)$/,
type: "asset/resource", type: 'asset/resource',
}, },
{ {
test: /\.(png|webp|jpg|jpeg|gif|svg)$/, test: /\.(png|webp|jpg|jpeg|gif|svg)$/,
type: "javascript/auto", type: 'javascript/auto',
use: [{ use: [{
loader: 'img-optimize-loader', loader: 'img-optimize-loader',
options: { options: {

View File

@ -10,7 +10,7 @@ const fs = require('fs');
//const autoprefixer = require('autoprefixer'); //const autoprefixer = require('autoprefixer');
const webpack = require('webpack'); const webpack = require('webpack');
const { const {
merge merge,
} = require('webpack-merge'); } = require('webpack-merge');
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
@ -54,7 +54,7 @@ const config = merge(common.webpack, {
}, },
module: { module: {
rules: [{ rules: [{ test: /\.tsx?$/, loader: 'ts-loader' }, {
test: /\.jsx?$/, test: /\.jsx?$/,
//exclude: /node_modules/, //exclude: /node_modules/,
use: { use: {
@ -103,14 +103,14 @@ const config = merge(common.webpack, {
}, },
{ {
test: /fontawesome([^.]+).(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/, test: /fontawesome([^.]+).(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
type: "asset/resource", type: 'asset/resource',
}, },
{ {
test: /\.(gif|png|jpg|jpeg|ttf|otf|eot|svg|webp|woff(2)?)$/, test: /\.(gif|png|jpg|jpeg|ttf|otf|eot|svg|webp|woff(2)?)$/,
type: "asset/resource", type: 'asset/resource',
}, { }, {
test: /\.(png|webp|jpg|jpeg|gif|svg)$/, test: /\.(png|webp|jpg|jpeg|gif|svg)$/,
type: "asset/resource", type: 'asset/resource',
},], },],
}, },
plugins: plugins, plugins: plugins,