File tree Expand file tree Collapse file tree 2 files changed +77
-0
lines changed
Expand file tree Collapse file tree 2 files changed +77
-0
lines changed Original file line number Diff line number Diff line change 1+ import { writeFile , unlink } from "fs/promises" ;
2+
3+ export const packageJson = ( json ) => {
4+ json . browserslist = "> 0.25%, not dead" ;
5+ Object . assign ( json . devDependencies , {
6+ "@swc/core" : "*" ,
7+ browserslist : "*" ,
8+ "swc-loader" : "*" ,
9+ "regenerator-runtime" : "*" ,
10+ "terser-webpack-plugin" : "*" ,
11+ } ) ;
12+ return json ;
13+ } ;
14+
15+ export const setup = async ( ) => {
16+ await writeFile (
17+ ".swcrc" ,
18+ JSON . stringify (
19+ {
20+ jsc : {
21+ parser : {
22+ syntax : "ecmascript" ,
23+ dynamicImport : true ,
24+ } ,
25+ } ,
26+ env : { } ,
27+ } ,
28+ null ,
29+ 2
30+ )
31+ ) ;
32+ } ;
33+
34+ export const teardown = async ( ) => {
35+ try {
36+ await unlink ( ".swcrc" ) ;
37+ } catch ( e ) { }
38+ } ;
39+
40+ export const config = ( content ) => `${ content }
41+
42+ var TerserPlugin = require("terser-webpack-plugin");
43+
44+ module.exports.module = module.exports.module || {};
45+ module.exports.module.rules = module.exports.module.rules || [];
46+ module.exports.module.rules.unshift({
47+ test: /\.(js|tsx?)$/,
48+ use: [
49+ {
50+ loader: "swc-loader"
51+ }
52+ ]
53+ });
54+
55+ module.exports.optimization = {
56+ minimizer: [new TerserPlugin({
57+ minify: TerserPlugin.swcMinify,
58+ })],
59+ };
60+ ` ;
Original file line number Diff line number Diff line change 1+ export const packageJson = ( json ) => {
2+ Object . assign ( json . devDependencies , {
3+ "terser-webpack-plugin" : "*" ,
4+ } ) ;
5+ return json ;
6+ } ;
7+
8+ export const config = ( content ) => `${ content }
9+
10+ var TerserPlugin = require("terser-webpack-plugin");
11+
12+ module.exports.optimization = {
13+ minimizer: [new TerserPlugin({
14+ minify: TerserPlugin.swcMinify,
15+ })],
16+ };
17+ ` ;
You can’t perform that action at this time.
0 commit comments