Skip to content

Commit

Permalink
Upgrade to webpack v5
Browse files Browse the repository at this point in the history
  • Loading branch information
pradeepnschrodinger committed Oct 8, 2024
1 parent d806994 commit 98313a6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 31 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
"rollup-plugin-terser": "^7.0.2",
"style-loader": "1.0.0",
"terser-webpack-plugin": "4.2.3",
"url-loader": "2.1.0",
"webpack": "^5.94.0",
"webpack-cli": "^4.3.0",
"webpack-dev-server": "^4.7.4"
Expand Down
29 changes: 20 additions & 9 deletions site/webpack-client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');

const isDev = process.env.NODE_ENV !== 'production';
const nodeEnv = process.env.NODE_ENV ?? 'development';
const isDev = nodeEnv !== 'production';

module.exports = {
mode: isDev ? 'development' : 'production',
Expand All @@ -14,7 +15,7 @@ module.exports = {

output: {
path: path.resolve(__dirname, '../__site__/'),
filename: isDev ? '[name].js' : '[name]-[hash].js',
filename: isDev ? '[name].js' : '[name]-[contentHash].js',
publicPath: '',
},

Expand All @@ -24,10 +25,15 @@ module.exports = {
rules: [
{
test: /\.md$/,
loader: [
'html-loader?{"minimize":false}',
use: [
{
loader: 'html-loader',
options: {
minimize: false,
},
},
path.join(__dirname, '../build_helpers/markdownLoader'),
].join('!'),
],
},
{
test: /\.js$/,
Expand Down Expand Up @@ -63,8 +69,10 @@ module.exports = {
},
{
test: /\.png$/,
loader: 'file-loader',
query: { mimetype: 'image/png', name: 'images/[name]-[hash].[ext]' },
type: 'asset/resource',
generator: {
filename: 'images/[name]-[contentHash].[ext]',
},
},
],
},
Expand All @@ -74,6 +82,9 @@ module.exports = {
'fixed-data-table-2/css': path.join(__dirname, '../src/css'),
'fixed-data-table-2': path.join(__dirname, '../src/index'),
},
fallback: {
url: false,
},
},

devServer: {
Expand All @@ -83,10 +94,10 @@ module.exports = {

plugins: [
new MiniCssExtractPlugin({
filename: isDev ? '[name].css' : '[name]-[hash].css',
filename: isDev ? '[name].css' : '[name]-[contentHash].css',
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.NODE_ENV': JSON.stringify(nodeEnv),
// 'process.env.NODE_ENV': JSON.stringify('production'),
__DEV__: isDev,
}),
Expand Down
27 changes: 20 additions & 7 deletions site/webpack-prerender.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');

const nodeEnv = process.env.NODE_ENV ?? 'development';
const isDev = process.env.NODE_ENV !== 'production';

module.exports = {
Expand All @@ -12,7 +13,9 @@ module.exports = {
output: {
path: path.resolve(__dirname, '../__site_prerender__/'),
filename: 'renderPath.js',
libraryTarget: 'commonjs2',
library: {
type: 'commonjs2',
},
},

target: 'node',
Expand All @@ -21,10 +24,15 @@ module.exports = {
rules: [
{
test: /\.md$/,
loader: [
'html-loader?{"minimize":false}',
use: [
{
loader: 'html-loader',
options: {
minimize: false,
},
},
path.join(__dirname, '../build_helpers/markdownLoader'),
].join('!'),
],
},
{
test: /\.js$/,
Expand All @@ -41,8 +49,10 @@ module.exports = {
},
{
test: /\.png$/,
loader: 'file-loader',
query: { mimetype: 'image/png', name: 'images/[name]-[hash].[ext]' },
type: 'asset/resource',
generator: {
filename: 'images/[name]-[contentHash].[ext]',
},
},
],
},
Expand All @@ -52,11 +62,14 @@ module.exports = {
'fixed-data-table-2/css': path.join(__dirname, '../src/css'),
'fixed-data-table-2': path.join(__dirname, '../src/index'),
},
fallback: {
url: false,
},
},

plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.NODE_ENV': JSON.stringify(nodeEnv),
__DEV__: isDev,
}),
],
Expand Down
14 changes: 0 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5997,11 +5997,6 @@ [email protected], mime@^1.4.1:
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==

mime@^2.4.4:
version "2.6.0"
resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367"
integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==

mimic-fn@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
Expand Down Expand Up @@ -8253,15 +8248,6 @@ uri-js@^4.2.2:
dependencies:
punycode "^2.1.0"

[email protected]:
version "2.1.0"
resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-2.1.0.tgz#bcc1ecabbd197e913eca23f5e0378e24b4412961"
integrity sha512-kVrp/8VfEm5fUt+fl2E0FQyrpmOYgMEkBsv8+UDP1wFhszECq5JyGF33I7cajlVY90zRZ6MyfgKXngLvHYZX8A==
dependencies:
loader-utils "^1.2.3"
mime "^2.4.4"
schema-utils "^2.0.0"

url-parse@^1.5.3:
version "1.5.10"
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.10.tgz#9d3c2f736c1d75dd3bd2be507dcc111f1e2ea9c1"
Expand Down

0 comments on commit 98313a6

Please sign in to comment.