New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-symfony

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-symfony - npm Package Compare versions

Comparing version

to
0.5.2

2

dist/index.d.ts
import type { Plugin } from "vite";
export default function (): Plugin;
export default function (options?: PluginOptions): Plugin;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const sirv_1 = __importDefault(require("sirv"));
const path_1 = require("path");

@@ -8,5 +12,15 @@ const fs_1 = require("fs");

const fileHelper_1 = require("./fileHelper");
/* not imported from vite because we don't want vite in package.json dependancy */
const FS_PREFIX = `/@fs/`;
const VALID_ID_PREFIX = `/@id/`;
const CLIENT_PUBLIC_PATH = `/@vite/client`;
const ENV_PUBLIC_PATH = `/@vite/env`;
const importQueryRE = /(\?|&)import=?(?:&|$)/;
const internalPrefixes = [FS_PREFIX, VALID_ID_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH];
const InternalPrefixRE = new RegExp(`^(?:${internalPrefixes.join("|")})`);
const isImportRequest = (url) => importQueryRE.test(url);
const isInternalRequest = (url) => InternalPrefixRE.test(url);
let viteConfig = null;
let entryPointsPath, assetsPath;
function default_1() {
let entryPointsPath;
function default_1(options = {}) {
return {

@@ -69,2 +83,27 @@ name: "symfony",

});
if (options.servePublic !== false) {
const serve = (0, sirv_1.default)("public", {
dev: true,
etag: true,
extensions: [],
setHeaders(res, pathname) {
// Matches js, jsx, ts, tsx.
// The reason this is done, is that the .ts file extension is reserved
// for the MIME type video/mp2t. In almost all cases, we can expect
// these files to be TypeScript files, and for Vite to serve them with
// this Content-Type.
if (/\.[tj]sx?$/.test(pathname)) {
res.setHeader("Content-Type", "application/javascript");
}
res.setHeader("Access-Control-Allow-Origin", "*");
},
});
devServer.middlewares.use(function viteServePublicMiddleware(req, res, next) {
// skip import request and internal requests `/@fs/ /@vite-client` etc...
if (isImportRequest(req.url) || isInternalRequest(req.url)) {
return next();
}
serve(req, res, next);
});
}
},

@@ -71,0 +110,0 @@ writeBundle(options, bundles) {

{
"name": "vite-plugin-symfony",
"version": "0.5.1",
"version": "0.5.2",
"description": "",

@@ -48,3 +48,6 @@ "main": "dist/index.js",

"node": "16.16.0"
},
"dependencies": {
"sirv": "^2.0.2"
}
}

@@ -39,3 +39,5 @@ # Vite plugin Symfony

/* reactRefresh(), // if you're using React */
symfonyPlugin(),
symfonyPlugin({
servePublic: true /* defaultValue */
}),
],

@@ -42,0 +44,0 @@

import type { Plugin, UserConfig } from "vite";
import sirv from "sirv";

@@ -10,6 +11,18 @@ import { resolve } from "path";

/* not imported from vite because we don't want vite in package.json dependancy */
const FS_PREFIX = `/@fs/`;
const VALID_ID_PREFIX = `/@id/`;
const CLIENT_PUBLIC_PATH = `/@vite/client`;
const ENV_PUBLIC_PATH = `/@vite/env`;
const importQueryRE = /(\?|&)import=?(?:&|$)/;
const internalPrefixes = [FS_PREFIX, VALID_ID_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH];
const InternalPrefixRE = new RegExp(`^(?:${internalPrefixes.join("|")})`);
const isImportRequest = (url: string): boolean => importQueryRE.test(url);
const isInternalRequest = (url: string): boolean => InternalPrefixRE.test(url);
let viteConfig = null;
let entryPointsPath: string, assetsPath: string;
let entryPointsPath: string;
export default function (): Plugin {
export default function (options: PluginOptions = {}): Plugin {
return {

@@ -80,2 +93,29 @@ name: "symfony",

});
if (options.servePublic !== false) {
const serve = sirv("public", {
dev: true,
etag: true,
extensions: [],
setHeaders(res, pathname) {
// Matches js, jsx, ts, tsx.
// The reason this is done, is that the .ts file extension is reserved
// for the MIME type video/mp2t. In almost all cases, we can expect
// these files to be TypeScript files, and for Vite to serve them with
// this Content-Type.
if (/\.[tj]sx?$/.test(pathname)) {
res.setHeader("Content-Type", "application/javascript");
}
res.setHeader("Access-Control-Allow-Origin", "*");
},
});
devServer.middlewares.use(function viteServePublicMiddleware(req, res, next) {
// skip import request and internal requests `/@fs/ /@vite-client` etc...
if (isImportRequest(req.url!) || isInternalRequest(req.url!)) {
return next();
}
serve(req, res, next);
});
}
},

@@ -82,0 +122,0 @@ writeBundle(options, bundles) {

@@ -40,1 +40,5 @@ type EntryPointsFile = {

};
type PluginOptions = {
servePublic?: boolean;
};