Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !979

Proof of concept: Plugin System

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/dceddia/plugin-poc into master Oct 28, 2016
  • Overview 3
  • Commits 1
  • Pipelines 0
  • Changes 3

Created by: dceddia

(This is related to issue #670 (closed))

This commit adds a "plugins" module and integrates it into the dev and prod build scripts.

The design and functionality is intentionally minimal, but it allows a user to write a plugin or series of plugins to manipulate the Webpack config as necessary. The example given in the plugins.js file shows a plugin that adds a SASS loader:

module.exports = function(webpackConfig) {
    webpackConfig.module.loaders.push({
      test: /\.scss$/,
      loaders: ["style", "css", "sass"]
    });
    return webpackConfig;
};

But conceivably any sort of Webpack config transformation could be done here.

Plugins are loaded and run, in order, from the plugins key in package.json. This would load a module named cra-plugin-sass, which would need to be npm install'd separately.

  "plugins": [
    "cra-plugin-sass"
  ]

We could also explore auto-discovery of plugins ala Babel or Karma, by searching for packages matching the "cra-plugin-*" prefix. However, the loading order does matter (since the config is transformed by every plugin in turn) and an array of plugins is more explicit.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/dceddia/plugin-poc