0.1.4 • Published 3 years ago

projen-javascript-configuration-file v0.1.4

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
3 years ago

npm version GitHub Workflow Status (branch) License

Javascript config file component for projen

WIP and subject to change

Assumptions

  • Config file supports ESM import/export (use .mjs file as needed)
  • Only a single export, which is a default export
  • Works best if export is a function (can work around that)

Usage

Add "projen-javascript-configuration-file" to devDeps in projenrc

Note: End a line with //! to remove it from the final output

In projenrc:

import { Configuration } from "webpack";

const projectName = project.name;
new JavascriptConfigComponent<Configuration>(
    project,
    "webpack.config.mjs",
    (webpackEnv) => {
      console.log("test"); //!
      return {
        name: projectName,
      };
    },
    {
      imports: [
        {
          module: "webpack-merge",
          nameImports: ["merge"],
        },
      ],
      variables: {
        projectName,
      },
    }
  );

Resulting webpack.config.mjs

import { merge } from "webpack-merge";
const projectName = "test-project";

export default () => {
    return {
        name: projectName,
    };
};