mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-17 05:02:23 +08:00
33 lines
991 B
JavaScript
33 lines
991 B
JavaScript
const path = require('path');
|
|
const shell = require('shelljs');
|
|
const chalk = require('chalk');
|
|
const log = require('npmlog');
|
|
|
|
const modulePath = path.resolve('./');
|
|
// eslint-disable-next-line import/no-dynamic-require
|
|
const packageJson = require(path.join(modulePath, 'package.json'));
|
|
|
|
shell.rm('-rf', 'dist');
|
|
|
|
const babel = path.join(__dirname, '..', 'node_modules', '.bin', 'babel');
|
|
const args = [
|
|
'--ignore tests,__tests__,test.js,stories/,story.jsx',
|
|
'--plugins "transform-runtime"',
|
|
'./src --out-dir ./dist',
|
|
'--copy-files',
|
|
].join(' ');
|
|
|
|
const command = `${babel} ${args}`;
|
|
const { code } = shell.exec(command, { silent: true });
|
|
|
|
if (code !== 0) {
|
|
log.error(`FAILED: ${chalk.bold(`${packageJson.name}@${packageJson.version}`)}`);
|
|
shell.exit(code);
|
|
}
|
|
|
|
const licence = path.join(__dirname, '..', 'LICENSE');
|
|
shell.cp(licence, './');
|
|
|
|
// eslint-disable-next-line no-console
|
|
console.log(chalk.gray(`Built: ${chalk.bold(`${packageJson.name}@${packageJson.version}`)}`));
|