Webpack(webpackConfig, function (arg1, arg2) { var html if (arg2.compilation.assets) { html = arg2.compilation.assets['index.html'].source() } else { html = '<!doctype html>' } // Due to a bug with the style-loader we have to "touch" a file // to force a rebundle after the initial one. Kudos to my colleague // Stephan for this one fs.writeFile('./public/index.html', html, function(err) { if (err) { console.log(err); } }) fs.writeFileSync(mainPath, fs.readFileSync(mainPath).toString()) console.log('Project is ready!') })
// Create the development bundle and print the deployment instructions. function build(previousFileSizes) { console.log('Creating development bundle...'); console.log('Please wait until webpack has build bundle.js file...'); webpack(config).run((err, stats) => { if (err) { printErrors('Failed to compile.', [err]); process.exit(1); } if (stats.compilation.errors.length) { printErrors('Failed to compile.', stats.compilation.errors); process.exit(1); } if (process.env.CI && stats.compilation.warnings.length) { printErrors('Failed to compile. When process.env.CI = true, warnings are treated as failures. Most CI servers set this automatically.', stats.compilation.warnings); process.exit(1); } console.log(chalk.green('Compiled successfully.')); console.log(); console.log('File sizes after gzip:'); console.log(); printFileSizesAfterBuild(stats, previousFileSizes); console.log(); }); }
webpack({ mode: 'production', entry: { main: path.resolve(__dirname, './index.js') }, output: {} }, (err, stats) => { if (!err) { const template = fs.readFileSync(path.resolve(__dirname, './index.tpl'), 'utf8') const code = Simplite.toCodeBlock(template) let jsContent = stats.compilation.assets['main.js']._value const render = ` module.exports = (data) => { data.__main__ = ${JSON.stringify(jsContent)} return Function('_this',${JSON.stringify(code)}).call({defaultAttr:v=>v},data); } ` fs.writeFileSync(path.resolve(__dirname, '../../dist/render.js'), render) fs.unlinkSync(path.resolve(__dirname, '../../dist/main.js')) } else { console.log(err) } })
const html = stats.compilation.assets['../index.html'].source(); const html2 = stats.compilation.assets['../index2.html'].source();
console.error(stats.compilation.errors); throw new Error(stats.compilation.errors);
if (stats.compilation.errors.length) { console.log(chalk.red('Failed to compile.')); console.log(stats.toString({ all: false, errors: true })); if (stats.compilation.warnings.length) { console.log(chalk.yellow('Compiled with warnings.')); console.log(stats.toString({ all: false, warnings: true })); stats.compilation.errors.length || stats.compilation.warnings.length ) { isCI && process.exit(1);
if (stats.compilation.errors.length > 0) { printErrors('Failed to compile.', stats.compilation.errors); process.exit(1); if (process.env.CI && stats.compilation.warnings.length > 0) { printErrors('Failed to compile.', stats.compilation.warnings); process.exit(1);
if (stats.compilation.errors.length) { printErrors('Failed to compile.', stats.compilation.errors); process.exit(1);
if (stats.compilation.errors.length) { printErrors('Failed to compile.', stats.compilation.errors); process.exit(1);
if (stats.compilation.errors.length) { console.log(chalk.red('Failed to compile.')); console.log(stats.toString({ all: false, errors: true })); if (stats.compilation.warnings.length) { console.log(chalk.yellow('Compiled with warnings.')); console.log(stats.toString({ all: false, warnings: true })); stats.compilation.errors.length || stats.compilation.warnings.length ) { isCI && process.exit(1);
if (stats.compilation.errors.length) { printErrors('Failed to compile.', stats.compilation.errors) process.exit(1)
if (stats.compilation.errors.length) { printErrors('Failed to compile.', stats.compilation.errors); process.exit(1);
if (stats.compilation.errors.length) { printErrors('Failed to compile.', stats.compilation.errors); process.exit(1);
if (stats.compilation.errors.length) { printErrors('Failed to compile.', stats.compilation.errors); process.exit(1);
if (stats.compilation.errors.length) { printErrors('Failed to compile.', stats.compilation.errors); process.exit(1);