🐊Putout plugin to convert webpack.config.js to rspack. Not bundled.
Renamed to @putout/plugin-rspack.
npm i putout @putout/plugin-rspack -D
- ✅ apply-asset-type;
- ✅ apply-global-define;
- ✅ apply-library-object;
- ✅ apply-rspack-import;
- ✅ apply-swc-loader;
- ✅ remove-webpackbar;
{
"rules": {
"rspack/apply-asset-type": "on",
"rspack/apply-global-define": "on",
"rspack/apply-library-object": "on",
"rspack/apply-rspack-import": "on",
"rspack/apply-swc-loader": "on",
"rspack/remove-webpackbar": "on"
}
}Checkout in 🐊Putout Editor.
export default {
module: {
rules: [{
test: /\.(png|gif|svg)$/,
use: {
loader: 'url-loader',
options: {
limit: 50_000,
},
},
}],
},
};export default {
module: {
rules: [{
test: /\.(png|gif|svg)$/,
type: 'asset',
parser: {
dataUrlCondition: {
maxSize: 50_000,
},
},
}],
},
};Checkout in 🐊Putout Editor.
Webpack replaces global with the global object in browser bundles, rspack does not do it for ESM modules (node.global has no effect there), so a bundle that touches global throws ReferenceError: global is not defined in the browser.
Use DefinePlugin to replace global with globalThis. Skipped for target: 'node'.
export default {
entry: './client/index.js',
};import {rspack} from '@rspack/core';
export default {
entry: './client/index.js',
plugins: [
new rspack.DefinePlugin({
global: 'globalThis',
}),
],
};Checkout in 🐊Putout Editor.
export default {
output: {
library: 'Deepword',
libraryTarget: 'var',
libraryExport: 'default',
},
};export default {
output: {
library: {
name: 'Deepword',
type: 'var',
export: 'default',
},
},
};Checkout in 🐊Putout Editor.
import webpack from 'webpack';
const {EnvironmentPlugin} = webpack;import {rspack} from '@rspack/core';
const {EnvironmentPlugin} = rspack;Checkout in 🐊Putout Editor.
export default {
module: {
rules: [{
test: /\.js$/,
loader: 'babel-loader',
}],
},
};export default {
module: {
rules: [{
test: /\.js$/,
loader: 'builtin:swc-loader',
options: {
jsc: {
parser: {
syntax: 'ecmascript',
},
},
env: {
targets: 'defaults',
},
},
}],
},
};import WebpackBar from 'webpackbar';
export default {
plugins: [new WebpackBar()],
};export default {
plugins: [],
};MIT