Skip to content

Commit

Permalink
fix: syncronize default dist folder
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Mar 13, 2021
1 parent f80bb99 commit e9780bb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
5 changes: 4 additions & 1 deletion core/core/src/node-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ export const findUpFile = (
return findUpFile(path.resolve(filePath, '..'), fileName, levels - 1);
};

export const defaultDistFolder = 'dist';

export const getDistName = (options: BuildProps): string => {
const dist = options.distFolder || path.join(process.cwd(), 'public');
const dist =
options.distFolder || path.join(process.cwd(), defaultDistFolder);
return dist;
};

Expand Down
5 changes: 3 additions & 2 deletions core/webpack-compile/src/args.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path';
import { defaultDistFolder } from '@component-controls/core/node-utils';
import yargs, { Options, Argv } from 'yargs';

export interface CliArgTypes {
Expand Down Expand Up @@ -57,7 +58,7 @@ export const defaultCliArgs: ArgOptions = [
alias: 'd',
description: 'distribution (bundle output) folder',
type: 'string',
default: 'public',
default: defaultDistFolder,
},
},
{
Expand All @@ -66,7 +67,7 @@ export const defaultCliArgs: ArgOptions = [
alias: 's',
description: 'static assets folder',
type: 'string',
default: path.join('dist', 'static'),
default: path.join(defaultDistFolder, 'static'),
},
},
{
Expand Down
7 changes: 5 additions & 2 deletions core/webpack-compile/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import fs from 'fs';
import { log, error } from '@component-controls/logger';
import { mergeBuildConfiguration } from '@component-controls/config';
import { BuildProps, defBundleName } from '@component-controls/core';
import { defaultDistFolder } from '@component-controls/core/node-utils';
import { LoadingStore } from '@component-controls/store';
import LoaderPlugin from '@component-controls/loader/plugin';
import {
Expand Down Expand Up @@ -39,7 +40,8 @@ export interface CompileResults {
*/
export const getBundleName = (): string => {
const args = cliArgs().parse();
let distFolder = args.dist || `${path.join(process.cwd(), 'public')}`;
let distFolder =
args.dist || `${path.join(process.cwd(), defaultDistFolder)}`;
if (!path.isAbsolute(distFolder)) {
distFolder = path.resolve(process.cwd(), distFolder);
}
Expand All @@ -64,7 +66,8 @@ const createConfig = (options: BuildProps): webpack.Configuration => {
distFolder: propDistFolder,
bundleName = defBundleName,
} = options;
let distFolder = propDistFolder || `${path.join(process.cwd(), 'public')}`;
let distFolder =
propDistFolder || `${path.join(process.cwd(), defaultDistFolder)}`;
if (!path.isAbsolute(distFolder)) {
distFolder = path.resolve(process.cwd(), distFolder);
}
Expand Down
8 changes: 6 additions & 2 deletions integrations/base-integration/src/webpack-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {
defaultCompileProps,
} from '@component-controls/core';
import { getSiteMap } from '@component-controls/routes';
import { getBundleName } from '@component-controls/core/node-utils';
import {
getBundleName,
defaultDistFolder,
} from '@component-controls/core/node-utils';
import { LoadingStore, loadStore } from '@component-controls/store';
import { log } from '@component-controls/logger';
import {
Expand Down Expand Up @@ -54,7 +57,8 @@ const createOptions = (buildOptions?: BuildProps): BuildProps => {
return acc;
}, {});

const distFolder = options.distFolder || path.join(process.cwd(), 'dist');
const distFolder =
options.distFolder || path.join(process.cwd(), defaultDistFolder);
const staticFolder = path.join(options.distFolder || distFolder, 'static');
return mergeConfig<BuildProps>(
mergeConfig(defaultCompileProps, {
Expand Down

0 comments on commit e9780bb

Please sign in to comment.