Skip to content
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

Change the package name. #6

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# vite-plugin-handlebars-import
# @yoichiro/vite-plugin-handlebars

This is a plugin that provides convenient features for using Handlebars with Vite.

Expand Down Expand Up @@ -46,7 +46,7 @@ This plugin automatically loads the `footer.hbs` file and includes it in the `ca
# Installation

```shell
npm install vite-plugin-handlebars-import --save-dev
npm install @yoichiro/vite-plugin-handlebars --save-dev
```

# Usage
Expand All @@ -56,11 +56,11 @@ To use this plugin in your Vite project, modify your `vite.config.js` or `vite.c
```javascript
// vite.config.js
import { defineConfig } from 'vite';
import handlebarsImportPlugin from 'vite-plugin-handlebars-import';
import handlebarsPlugin from '@yoichiro/vite-plugin-handlebars';

export default defineConfig({
plugins: [
handlebarsImportPlugin()
handlebarsPlugin()
]
});
```
Expand All @@ -72,30 +72,43 @@ This plugin can be configured with the following options:
* `templateFileExtension` (string) - Specifies the extension of Handlebars template files. Defaults to `hbs` if omitted.
* `partialDirectoryPath` (string) - Specifies the path to the directory containing partial template files to be included in Handlebars template files. If omitted, partial template files are not registered.

These options can be specified as arguments to the `handlebarsImportPlugin` function. Below is an example that specifies `handlebars` as the template file extension and `templates/partials` as the directory containing partial template files.
These options can be specified as arguments to the `handlebarsPlugin` function. Below is an example that specifies `handlebars` as the template file extension and `templates/partials` as the directory containing partial template files.

```javascript
// vite.config.js
import { defineConfig } from 'vite';
import handlebarsImportPlugin from 'vite-plugin-handlebars-import';
import handlebarsPlugin from '@yoichiro/vite-plugin-handlebars';
import path from 'path';

export default defineConfig({
plugins: [
handlebarsImportPlugin({
handlebarsPlugin({
templateFileExtension: 'handlebars',
partialDirectoryPath: path.resolve(__dirname, 'templates', 'partials')
})
]
});
```

# Samples

The `integration` directory contains a sample Vite project using this plugin. You can start this sample project by following these steps:

```sh
$ git clone https://github.com/yoichiro/vite-plugin-handlebars.git
$ cd vite-plugin-handlebars
$ npm install
$ npm run integration-test
```

After the development server starts, please access `http://localhost:5173` in your web browser.

# Contributing

If you would like to contribute to this plugin, please follow these steps:

1. Register an issue and describe what you would like to contribute.
2. Fork this repository, create a new branch, make your code changes, and submit a pull request.
2. When you want to contribute by sending code, fork this repository, create a new branch, make your code changes, and submit a pull request.

# License

Expand Down
2 changes: 1 addition & 1 deletion integration/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import template from '../templates/template.handlebars';

window.addEventListener('load', () => {
const app = document.getElementById('app');
app.innerHTML = template({ name: 'Handlebars Import Vite Plugin' });
app.innerHTML = template({ name: 'Handlebars Vite Plugin' });
});
4 changes: 2 additions & 2 deletions integration/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { defineConfig } from 'vite';
import handlebarsImportPlugin from '../dist/index';
import handlebarsPlugin from '../dist/index';
import { resolve } from 'path';

export default defineConfig({
root: 'integration',
plugins: [
handlebarsImportPlugin({
handlebarsPlugin({
templateFileExtension: '.handlebars',
partialsDirectoryPath: resolve(__dirname, 'partials'),
}),
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "vite-plugin-handlebars-import",
"version": "1.0.1",
"name": "@yoichiro/vite-plugin-handlebars",
"version": "1.0.2",
"author": {
"name": "Yoichiro Tanaka",
"email": "yoichiro6642@gmail.com",
"url": "https://github.com/yoichiro"
},
"repository": "github:yoichiro/vite-plugin-handlebars-import",
"homepage": "https://github.com/yoichiro/vite-plugin-handlebars-import",
"repository": "github:yoichiro/vite-plugin-handlebars",
"homepage": "https://github.com/yoichiro/vite-plugin-handlebars",
"bugs": {
"url": "https://github.com/yoichiro/vite-plugin-handlebars-import/issues"
"url": "https://github.com/yoichiro/vite-plugin-handlebars/issues"
},
"dependencies": {
"handlebars": "^4.7.8",
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import {
transform,
} from './internal';

export type HandlebarsImportPluginOptions = {
export type HandlebarsPluginOptions = {
templateFileExtension?: string;
partialsDirectoryPath?: string;
};

export default function handlebarsImportPlugin(
options: HandlebarsImportPluginOptions = {}
export default function handlebarsPlugin(
options: HandlebarsPluginOptions = {}
): Plugin {
const templateFileExtension = decideTemplateFileExtension(
options.templateFileExtension
Expand All @@ -22,7 +22,7 @@ export default function handlebarsImportPlugin(
options.partialsDirectoryPath
);
return {
name: 'vite-plugin-handlebars-import',
name: '@yoichiro/vite-plugin-handlebars',
transform(code, id) {
if (!id.endsWith(templateFileExtension)) {
return null;
Expand Down
8 changes: 4 additions & 4 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { describe, expect, test } from 'vitest';
import handlebarsImportPlugin from '../src';
import handlebarsPlugin from '../src';
import path from 'path';

describe('handlebarsImportPlugin', () => {
describe('handlebarsPlugin', () => {
test('should return the plugin name', () => {
const plugin = handlebarsImportPlugin({ partialsDirectoryPath: '' });
expect(plugin.name).toEqual('vite-plugin-handlebars-import');
const plugin = handlebarsPlugin({ partialsDirectoryPath: '' });
expect(plugin.name).toEqual('@yoichiro/vite-plugin-handlebars');
});
});