mirror of
https://github.com/JosunLP/UserScriptProjectTemplate.git
synced 2025-10-14 09:00:11 +00:00

- Updated package.json to include new scripts for development, production builds, linting, formatting, and cleaning. - Added ESLint and Prettier for code quality and formatting. - Refactored main application class to extend EventEmitter and manage modules. - Introduced ExampleModule to demonstrate module structure and functionality. - Created utility classes for DOM manipulation, event handling, and persistent storage. - Added TypeScript definitions for UserScript environment. - Improved TypeScript configuration with stricter checks and path aliases. - Updated Vite configuration to handle development and production builds more effectively. - Enhanced user script header generation to support environment-specific configurations.
33 lines
847 B
TypeScript
33 lines
847 B
TypeScript
import { resolve } from "path";
|
|
import { defineConfig } from "vite";
|
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
import pkgjsn from "./package.json";
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const isDev = mode === 'development';
|
|
|
|
return {
|
|
build: {
|
|
rollupOptions: {
|
|
input: resolve(__dirname, "src/index.ts"),
|
|
output: {
|
|
entryFileNames: `${pkgjsn.name}${isDev ? '.dev' : ''}.user.js`,
|
|
dir: resolve(__dirname, "dist"),
|
|
},
|
|
},
|
|
sourcemap: isDev ? "inline" : false,
|
|
minify: isDev ? false : 'terser',
|
|
},
|
|
plugins: [tsconfigPaths()],
|
|
resolve: {
|
|
extensions: [".tsx", ".ts", ".js"],
|
|
alias: {
|
|
'@': resolve(__dirname, 'src'),
|
|
},
|
|
},
|
|
define: {
|
|
__DEV__: isDev,
|
|
__VERSION__: JSON.stringify(pkgjsn.version),
|
|
},
|
|
};
|
|
});
|