MCPcopy
hub / github.com/GrapesJS/grapesjs / buildWebpack

Function buildWebpack

packages/cli/src/build.ts:95–140  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93 isVerb && log(chalk.yellow('Build config:\n'), opts, '\n');
94
95 const buildWebpack = () => {
96 const buildConf = {
97 ...webpackConfig({
98 production: 1,
99 args: buildWebpackArgs(opts),
100 cmdOpts: opts,
101 }),
102 ...normalizeJsonOpt(opts, 'config'),
103 };
104
105 if (dts === 'only') {
106 return buildDeclaration(opts);
107 }
108
109 webpack(buildConf, async (err, stats) => {
110 const errors = err || (stats ? stats.hasErrors() : false);
111 const statConf = {
112 hash: false,
113 colors: true,
114 builtAt: false,
115 entrypoints: false,
116 modules: false,
117 ...normalizeJsonOpt(opts, 'stats'),
118 };
119
120 if (stats) {
121 opts.statsOutput && fs.writeFileSync(rootResolve(opts.statsOutput), JSON.stringify(stats.toJson()));
122 isVerb && log(chalk.yellow('Stats config:\n'), statConf, '\n');
123 const result = stats.toString(statConf);
124 log(result, '\n');
125 }
126
127 await buildLocale(opts);
128
129 if (dts !== 'skip') {
130 await buildDeclaration(opts);
131 }
132
133 if (errors) {
134 printError(`Error during building`);
135 console.error(err);
136 } else {
137 printRow('Building completed successfully!');
138 }
139 });
140 };
141
142 if (opts.patch) {
143 isVerb && log(chalk.yellow('Patch the version'), '\n');

Callers 1

build.tsFile · 0.85

Calls 9

buildWebpackArgsFunction · 0.90
normalizeJsonOptFunction · 0.90
rootResolveFunction · 0.90
logFunction · 0.90
printErrorFunction · 0.90
printRowFunction · 0.90
buildDeclarationFunction · 0.85
buildLocaleFunction · 0.85
toStringMethod · 0.80

Tested by

no test coverage detected