Skip to content

Failed to fetch dynamically imported module #30

@250king

Description

@250king

After add your plugin in the vite configure file and build the production asset. I try to open it but failed:

Failed to fetch dynamically imported module: http://localhost:4173/assets/chunk-!~%7B002%7D~.js

image

import {defineConfig} from 'vite'
import react from '@vitejs/plugin-react-swc'
import obfuscator from 'rollup-plugin-obfuscator'
import path from "path";

// https://vite.dev/config/
export default defineConfig({
    plugins: [
        react(),
        obfuscator({
            global: true,
            options: {
                compact: true,
                controlFlowFlattening: true,
                controlFlowFlatteningThreshold: 1,
                deadCodeInjection: true,
                deadCodeInjectionThreshold: 1,
                debugProtection: true,
                debugProtectionInterval: 1000,
                disableConsoleOutput: true,
                identifierNamesGenerator: 'hexadecimal',
                log: false,
                numbersToExpressions: true,
                renameGlobals: false,
                selfDefending: true,
                simplify: true,
                splitStrings: true,
                splitStringsChunkLength: 5,
                stringArray: true,
                stringArrayCallsTransform: true,
                stringArrayEncoding: ['base64'],
                stringArrayIndexShift: true,
                stringArrayRotate: true,
                stringArrayShuffle: true,
                stringArrayWrappersCount: 5,
                stringArrayWrappersChainedCalls: true,
                stringArrayWrappersParametersMaxCount: 5,
                stringArrayWrappersType: 'function',
                stringArrayThreshold: 1,
                transformObjectKeys: true,
                unicodeEscapeSequence: true
            }
        })
    ],
    resolve: {
        alias: {
            // eslint-disable-next-line no-undef
            '@': path.resolve(__dirname, './src'),
        }
    },
    build: {
        minify: 'esbuild',
        target: "es2015",
        rollupOptions: {
            output: {
                entryFileNames: `assets/index-[hash].js`,
                chunkFileNames: `assets/chunk-[hash].js`,
                assetFileNames: `assets/[name].[ext]`
            }
        }
    },
    esbuild: {
        drop: ['console', 'debugger'],
    }
})

Is it a bug? Or something is wrong with my configure file?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions