Skip to content

Commit

Permalink
Add redirects file to build folder
Browse files Browse the repository at this point in the history
  • Loading branch information
schiehll committed May 28, 2019
1 parent d7068f1 commit c9b5a1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ exports.default = void 0;

var _path = _interopRequireDefault(require("path"));

var _fs = _interopRequireDefault(require("fs"));

var _shelljs = _interopRequireDefault(require("shelljs"));

var _chalk = _interopRequireDefault(require("chalk"));
Expand All @@ -18,13 +20,17 @@ var _default = () => {

const webpackConfig = _path.default.resolve(__dirname, '../webpack/webpack.config.js');

const kerbsPublic = _path.default.resolve(process.cwd(), 'kerbs_public');

console.log(_chalk.default.cyan('Building kerbs...\n'));

_shelljs.default.rm('-rf', _path.default.resolve(process.cwd(), 'kerbs_public'));
_shelljs.default.rm('-rf', kerbsPublic);

const code = _shelljs.default.exec(`node ${webpackExec} --mode production --config ${webpackConfig}`).code;

if (code === 0) {
_fs.default.writeFileSync(`${kerbsPublic}/_redirects`, '/* /index.html 200');

console.log(_chalk.default.green('\nSuccessfully built kerbs! Check kerbs_public folder.'));
}
};
Expand Down
6 changes: 5 additions & 1 deletion cli/build.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import path from 'path'
import fs from 'fs'
import shell from 'shelljs'
import chalk from 'chalk'

export default () => {
const webpackExec = path.resolve(__dirname, '../node_modules/.bin/webpack')
const webpackConfig = path.resolve(__dirname, '../webpack/webpack.config.js')
const kerbsPublic = path.resolve(process.cwd(), 'kerbs_public')

console.log(chalk.cyan('Building kerbs...\n'))

shell.rm('-rf', path.resolve(process.cwd(), 'kerbs_public'))
shell.rm('-rf', kerbsPublic)
const code = shell.exec(
`node ${webpackExec} --mode production --config ${webpackConfig}`
).code

if (code === 0) {
fs.writeFileSync(`${kerbsPublic}/_redirects`, '/* /index.html 200')

console.log(
chalk.green('\nSuccessfully built kerbs! Check kerbs_public folder.')
)
Expand Down

0 comments on commit c9b5a1a

Please sign in to comment.