Skip to content

Commit

Permalink
feat: add npm
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokrip committed Feb 8, 2025
1 parent a84d4b2 commit fe4a49f
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 8 deletions.
Empty file added build/.gitkeep
Empty file.
Empty file added build/types/.gitkeep
Empty file.
6 changes: 6 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Echo, {echoDefault} from "./lib/echo"

export {
Echo,
echoDefault
}
27 changes: 27 additions & 0 deletions lib/echo.ts
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
"use strict";

import Echo from "./core/Echo";
import { Effect } from "./types/enum/effect";

function generatedOption(effect: VisualEffects): EchoDefaultOptions {
if(!["wave", "pulse", "flash"].includes(effect)) {
throw new Error("There is no such effect")
}

const options: EchoDefaultOptions = {
visualEffect: effect,
sound: null,
delay: 0,
vibration: false,
duration: 500,
color: "#3677c6",
size: 100
}

return options ? options : null
}

const options = generatedOption(Effect.PULSE)
const echo = new Echo(options);

export {echo as echoDefault}
export default Echo;
1 change: 0 additions & 1 deletion lib/index.ts

This file was deleted.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
"type": "commonjs",
"main": "index.js",
"scripts": {
"build:dev": "webpack",
"build:prod": "webpack"
"build:dev": "webpack --env mode=development",
"build:prod": "webpack --env mode=production"
},
"devDependencies": {
"@eslint/js": "^9.19.0",
"eslint": "^9.19.0",
"globals": "^15.14.0",
"html-webpack-plugin": "^5.6.3",
"ts-loader": "^9.5.2",
"ts-node": "^10.9.2",
"typescript": "^5.7.3",
Expand Down
19 changes: 14 additions & 5 deletions webpack.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
import webpack from "webpack";
import path from 'path';

const webpackConfig = (env: any) => {
type TypeBuild = "development" | "production"

interface EnvVariables {
mode: TypeBuild
}


const webpackConfig = (env: EnvVariables) => {
const isDevevelopment = env.mode === "development"
const isProduction = env.mode === "production"

const config: webpack.Configuration = {
mode: env.mode ?? "development",
entry: path.resolve(__dirname, "lib", "index.ts"),
entry: path.resolve(__dirname, "index.ts"),
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].[contenthash].js",
clean: true
},

module: {
rules: [
{
Expand All @@ -23,11 +32,11 @@ const webpackConfig = (env: any) => {
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},

}

return config;
}


export default webpackConfig;
export default webpackConfig;

0 comments on commit fe4a49f

Please sign in to comment.