Skip to content

πŸ’‘[Feature]: Create one task for bundle & package each (Fix - 386) #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,23 @@ Sign-in is also required for some actions to work properly like the deploy actio

The extension shows all possible Gulp tasks one may run on an SPFx project. The tasks allow you to clean, bundle, package, serve the project with a single click.

![Gulp Tasks](./assets/images/tasks.png)
![Gulp Tasks](./assets/images/tasks2.png)

- **gulp bundle**

![Bundle local](./assets/images/bundle-local.gif)

- **gulp bundle --ship**

![Bundle `production`](./assets/images/bundle-production.gif)

- **gulp package-solution**

![Package local](./assets/images/package-local.gif)

- **gulp package-solution --ship**

![Bundle `production`](./assets/images/package-production.gif)

[Check out our docs for more details](https://github.com/pnp/vscode-viva/wiki/5.4-Gulp-tasks)

Expand Down
Binary file added assets/images/bundle-local.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/bundle-production.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/package-local.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/package-production.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/tasks2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/walkthrough/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ deploy-azure-storage - Deploys client-side solution project assets to Azure Stor

SPFx Toolkit VS Code extension shows all possible Gulp tasks one may run on an SPFx project. Don't worry about remembering all the commands, just click on the task you want to run and the extension will do the rest.

![Gulp Tasks](../images/tasks.png)
![Gulp Tasks](../images/tasks2.png)

[Check out our docs for more details](https://github.com/pnp/vscode-viva/wiki/5.4-Gulp-tasks)
6 changes: 6 additions & 0 deletions src/constants/Commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export const Commands = {
// Webviews
samplesGallery: `${EXTENSION_NAME}.samplesGallery`,

// Bundle
bundleProject: `${EXTENSION_NAME}.bundleProject`,

// Package
packageProject: `${EXTENSION_NAME}.packageProject`,

// Serving
serveProject: `${EXTENSION_NAME}.serveProject`,

Expand Down
6 changes: 2 additions & 4 deletions src/panels/CommandPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,10 @@ export class CommandPanel {
private static taskTreeView() {
const taskCommands: ActionTreeItem[] = [
new ActionTreeItem('Build project', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp build'),
new ActionTreeItem('Bundle project (local)', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp bundle'),
new ActionTreeItem('Bundle project (production)', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp bundle --ship'),
new ActionTreeItem('Bundle project', '', { name: 'debug-start', custom: false }, undefined, Commands.bundleProject),
new ActionTreeItem('Clean project', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp clean'),
new ActionTreeItem('Deploy project assets to Azure Storage', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp deploy-azure-storage'),
new ActionTreeItem('Package (local)', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp package-solution'),
new ActionTreeItem('Package (production)', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp package-solution --ship'),
new ActionTreeItem('Package', '', { name: 'debug-start', custom: false }, undefined, Commands.packageProject),
new ActionTreeItem('Serve', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp serve'),
new ActionTreeItem('Serve (nobrowser)', '', { name: 'debug-start', custom: false }, undefined, Commands.executeTerminalCommand, 'gulp serve --nobrowser'),
new ActionTreeItem('Serve from configuration', '', { name: 'debug-start', custom: false }, undefined, Commands.serveProject),
Expand Down
34 changes: 34 additions & 0 deletions src/services/executeWrappers/TerminalCommandExecuter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export class TerminalCommandExecuter {
subscriptions.push(
commands.registerCommand(Commands.serveProject, TerminalCommandExecuter.serveProject)
);
subscriptions.push(
commands.registerCommand(Commands.bundleProject, TerminalCommandExecuter.bundleProject)
);
subscriptions.push(
commands.registerCommand(Commands.packageProject, TerminalCommandExecuter.packageProject)
);
subscriptions.push(
commands.registerCommand(Commands.executeTerminalCommand, TerminalCommandExecuter.runCommand)
);
Expand Down Expand Up @@ -93,6 +99,34 @@ export class TerminalCommandExecuter {
commands.executeCommand(Commands.executeTerminalCommand, `gulp serve --config=${answer}`);
}

public static async bundleProject() {
const tasks = ['local','production'];
const answer = await window.showQuickPick(tasks, {
title: 'Select the target environment',
ignoreFocusOut: true
});

if(!answer) {
return;
}

commands.executeCommand(Commands.executeTerminalCommand, answer === 'local' ? 'gulp bundle' : 'gulp bundle --ship');
}

public static async packageProject() {
const tasks = ['local','production'];
const answer = await window.showQuickPick(tasks, {
title: 'Select the target environment',
ignoreFocusOut: true
});

if(!answer) {
return;
}

commands.executeCommand(Commands.executeTerminalCommand, answer === 'local' ? 'gulp package-solution' : 'gulp package-solution --ship');
}

/**
* Initializes the shell path for executing terminal commands.
* If the shell path is an object with a `path` property, it sets the `shellPath` to that value.
Expand Down