-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from KidkArolis/rspack-improvements
Rspack improvements
- Loading branch information
Showing
13 changed files
with
2,128 additions
and
1,281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
const rspack = require('@rspack/core') | ||
const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin') | ||
const wpConf = require('./webpack.config') | ||
|
||
module.exports = async function (options, log) { | ||
log.info('Generating report...') | ||
process.env.NODE_ENV = 'production' | ||
const webpackConfigs = await wpConf(options, log) | ||
const webpackConfig = !options.target.modern ? webpackConfigs.legacy : webpackConfigs.modern | ||
webpackConfig.plugins = webpackConfig.plugins || [] | ||
webpackConfig.plugins.push(new RsdoctorRspackPlugin()) | ||
const compiler = rspack(webpackConfig) | ||
compiler.run(async function (err, stats) { | ||
if (err) return console.log(err) | ||
if (options.static && isDir(path.join(options.dir, options.static))) { | ||
await fs.copy(path.join(options.dir, options.static), path.join(options.dir, options.dist, options.static)) | ||
} | ||
console.log( | ||
stats.toString({ | ||
colors: true | ||
}) | ||
) | ||
}) | ||
} | ||
|
||
function isDir(path) { | ||
try { | ||
return fs.lstatSync(path).isDirectory(path) | ||
} catch (err) { | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.