npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

concat-text-webpack-plugin-2023

v1.0.1

Published

Concatenate and extract text files. Forked + updated for Node 18, 19, 20 and Webpack 5

Downloads

1,666

Readme

CI Status Publish Status NPM version License

concat-text-webpack-plugin-2023

This has been forked from the original repo which has been archived / made read only.

It is to fix this error which is found when using Node 18 or above and have webpack-concat-text-plugin in a nested dependency. The error is because the package is capped to Node 16, and Webpack 4.

error [email protected]: The engine "node" is incompatible with this module. Expected version ">=8 <=16". Got "18.16.0"
error Found incompatible module.

The original code has been changed to work with the major breaking changes in Webpack 5, and tested against Node 16, 18, 19, 20. It'll be kept up to date with new Webpack + Node versions. It keeps the same API as the original package.

Over-writing a Nested Dependency

Yarn

Remove your existing webpack-concat-text-plugin

yarn remove webpack-concat-text-plugin

Add this webpack-concat-text-plugin-2023

yarn add webpack-concat-text-plugin-2023

Then update your package.json with the resolutions block

# package.json

"resolutions": {
    "**/concat-text-webpack-plugin": "npm:concat-text-webpack-plugin-2023"
}

It works by replacing any nested imports of concat-text-webpack-plugin with concat-text-webpack-plugin-2023, with the version specified in your dependencies.

NPM

Remove your existing webpack-concat-text-plugin

npm remove webpack-concat-text-plugin

Add this webpack-concat-text-plugin-2023

npm i -D webpack-concat-text-plugin-2023

For npm use overrides to override the entire package with a completely different package.

# package.json 

"overrides": {
  "dependency": {
    "concat-text-webpack-plugin": "npm:concat-text-webpack-plugin-2023"
  }
}

Original README

The ConcatTextPlugin extracts and concatenates text files from a specified glob path into a single file. This is not intended to be used to extract frontend asset files, like stylesheets (use the mini-css-extract-plugin for this). Instead, this plugin is helpful when dealing with raw text assets that have been split into multiple files for code modularisation purposes, but need to be consolidated for consumption by e.g. the project's backend system.

Usage

new ConcatTextPlugin({
    files: "res/**/*.properties",
    name: "values.properties",
    outputPath: "cache/",
})

The above configuration will look for .properties files under the res/ folder (relative to the Webpack config file location) and concatenate them into a single file named values.properties under the cache/ directory, which is relative to the Webpack output path.

Options

files (string)

The glob string to get the list of files that should be concatenated.

name (string, default: same as Webpack output.filename)

The name of the output file. If it is not specified, the output.filename and the files glob string file extension will be used as name. If the glob string doesn't have an extension, the name won't have one either:

module.exports = {
    output: {
        path: "dist/",
        filename: "app.js"
    },
    plugins: [
        new ConcatTextPlugin({
            files: "res/**/*",
            outputPath: "static"
        })
    ]
}

The example above will generate a concatenated file dist/static/app (without a file extension) containing everything under res/. The output file won't have a file extension as well if the glob string matches multiple file types:

module.exports = {
    output: {
        path: "dist/",
        filename: "app.js"
    },
    plugins: [
        new ConcatTextPlugin({
            files: "res/**/*.{txt,properties}",
            outputPath: "static"
        })
    ]
}

Some other examples would be *.js?(x) or *.+(md|markdown). Basically, if the file extension is not exact, the output file won't have one.

So, if you want to explicitly set the file extension for the concatenated file while still matching multiple types, the name options needs to be set. However, in case you don't want to set a static file name and instead prefer to just use the output.filename option of your Webpack config, the [name] placeholder can be of help:

module.exports = {
    output: {
        path: "dist/",
        filename: "app.js"
    },
    plugins: [
        new ConcatTextPlugin({
            files: "res/**/*.{md,markdown}",
            outputPath: "docs",
            name: "[name].md"
        })
    ]
}

outputPath (string, default: same as Webpack output.path)

Specify where the concatenated file should be placed, relative to the Webpack output path. You might also set it to an absolute path. Omitting this option will place the concatenated file at your Webpack output path.

module.exports = {
    output: {
        path: "dist/",
        filename: "app.js"
    },
    plugins: [
        new ConcatTextPlugin({
            files: "res/**/*.md",
            name: "docs.md"
        })
    ]
}

The configuration seen above will write a markdown file dist/docs.md containing every markdown file it could find under the res/ directory.

Tests

There are some basic snapshot tests to assert the output of the loader.

npm test

Publishing

To release a new version of this package, make sure to have the latest changes in the master branch, or at the very least, the changes that should be in a release.

  1. Run npm run release -- <new-version> in master. This will create a new release commit and git tag, as well as adjust the version in the package.json and package-lock.json.

The underlying script uses npm version to edit the package.json files and to commit/tag the changes for the release with the specified version. Refer to the npm documentation for more details.

  1. Push the commit and tag to master
  2. Create a new release on the GitHub Releases Page and specify the existing tag

A GitHub Action will now test and publish the new release.

License

MIT