soranoo / next-css-obfuscator

A package deeply inspired by PostCSS-Obfuscator but for Next.js.
https://next-css-obfuscator.vercel.app
MIT License
83 stars 3 forks source link

[BUG] Missing `<!DOCTYPE html>` after obfuscated #32

Closed hoangnhan2ka3 closed 8 months ago

hoangnhan2ka3 commented 8 months ago

Type

Checklist

  1. [x] Updated the package to the latest version
  2. [x] Read all documentation
  3. [x] No related issue
  4. [x] Meaningful issue title

Environment

Describe the bug Missing <!DOCTYPE html> after obfuscated.

Just happen in versions later than v2.2.10: hoangnhan.co.uk: v2.2.10 hoangnhan.uk: v2.2.14

I've just realized when see this message from console:

image

To Reproduce Steps to reproduce the behavior: Just run the package at latest version v2.2.14

Expected behavior

image

Screenshots

image

Config

module.exports = {
    enable: true, // Enable or disable the plugin.
    mode: "random", // Obfuscate mode, "random" or "simplify".
    buildFolderPath: ".next", // Build folder of your project.
    classConversionJsonFolderPath: "./css-obfuscator", // The folder path to store the before obfuscate and after obfuscated classes conversion table.
    refreshClassConversionJson: process.env.NODE_ENV !== "production", // Refresh the class conversion JSON file.

    classLength: 6, // Length of the obfuscated class name.
    classPrefix: "n", // Prefix of the obfuscated class name.
    classSuffix: "", // Suffix of the obfuscated class name.

    classIgnore: [
        "no-transition",
        "transform",
        "ltr",
        "rtl",
                "loading",
        "spinner",
        /progress.*/,
        /fa-.*/,
        /__variable_.*/,
        /__className_.*/,
        /os-.*/,
    ], // The class names to be ignored during obfuscation.

    allowExtensions: [".jsx", ".tsx", ".js", ".ts", ".html", ".rsc"], // The file extensions to be processed.

    contentIgnoreRegexes: [/\.jsxs\)\("\w+"/g], // The regexes to match the file content to be ignored during obfuscation.

    whiteListedFolderPaths: [], // Only obfuscate files in these folders

    blackListedFolderPaths: [
               "./.next/cache",
               /\.next\/cache/,
               /\.next\/.*\/\w+-image.*/,
               /\.next\/.*\/edge-chunks/,
        ], // Don't obfuscate files in these folders

    enableMarkers: false, // Enable or disable the obfuscate marker classes.
    markers: ["obf"], // Classes that indicate component(s) need to obfuscate.
    removeMarkersAfterObfuscated: true, // Remove the obfuscation markers from HTML elements after obfuscation.

    removeOriginalCss: true, // Delete original CSS from CSS files if it has a obfuscated version.

    generatorSeed: "84817818898", // The seed for the random generator.

    //! Experimental feature (Alpha)
    enableJsAst: false, // Whether to obfuscate JS files using abstract syntax tree parser (Experimental feature)

    logLevel: "info", // Log level
};

Related files

Not obfuscate:

index.html.txt

After obfuscated:

index.html.txt