How to use the parcel-bundler/src/utils/fs.writeFile function in parcel-bundler

To help you get started, we’ve selected a few parcel-bundler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kevincharm / parcel-plugin-web-extension / src / WebExtensionPackager.js View on Github external
// Write the manifest.json
        const bundlePath = path.parse(this.bundle.name)
        const contents = await this.resolveAssetContents(asset)
        const hotReloadScriptFilename = path.resolve(
            bundlePath.dir,
            'hot-reload.js'
        )
        await fs.writeFile(hotReloadScriptFilename, hotReloadScript, {
            encoding: 'utf8'
        })
        const manifestJsonFilename = path.resolve(
            bundlePath.dir,
            bundlePath.name + '.json'
        )
        await fs.writeFile(manifestJsonFilename, contents, { encoding: 'utf8' })

        // Package the extension (XPI/CRX)
        const zipped = await zipDir(this.options.outDir)
        const zippedFilename = path.resolve(
            artifactsDir,
            bundlePath.name + '.zip'
        )
        this.size = zipped.length
        await fs.writeFile(zippedFilename, zipped)
    }
github kevincharm / parcel-plugin-web-extension / src / WebExtensionPackager.js View on Github external
async addAsset(asset) {
        const artifactsDir = path.resolve(
            asset.options.outDir,
            '..',
            'artifacts'
        )
        await fs.mkdirp(artifactsDir)

        // Write the manifest.json
        const bundlePath = path.parse(this.bundle.name)
        const contents = await this.resolveAssetContents(asset)
        const hotReloadScriptFilename = path.resolve(
            bundlePath.dir,
            'hot-reload.js'
        )
        await fs.writeFile(hotReloadScriptFilename, hotReloadScript, {
            encoding: 'utf8'
        })
        const manifestJsonFilename = path.resolve(
            bundlePath.dir,
            bundlePath.name + '.json'
        )
        await fs.writeFile(manifestJsonFilename, contents, { encoding: 'utf8' })

        // Package the extension (XPI/CRX)
        const zipped = await zipDir(this.options.outDir)
        const zippedFilename = path.resolve(
            artifactsDir,
            bundlePath.name + '.zip'
        )
        this.size = zipped.length
        await fs.writeFile(zippedFilename, zipped)
github kevincharm / parcel-plugin-web-extension / src / WebExtensionPackager.js View on Github external
encoding: 'utf8'
        })
        const manifestJsonFilename = path.resolve(
            bundlePath.dir,
            bundlePath.name + '.json'
        )
        await fs.writeFile(manifestJsonFilename, contents, { encoding: 'utf8' })

        // Package the extension (XPI/CRX)
        const zipped = await zipDir(this.options.outDir)
        const zippedFilename = path.resolve(
            artifactsDir,
            bundlePath.name + '.zip'
        )
        this.size = zipped.length
        await fs.writeFile(zippedFilename, zipped)
    }