plugin-generator.js 965 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. const path = require("path");
  2. const _ = require("lodash");
  3. const webpackGenerator = require("./webpack-generator");
  4. /**
  5. * A yeoman generator class for creating a webpack
  6. * plugin project. It adds some starter plugin code
  7. * and runs `webpack-defaults`.
  8. *
  9. * @class PluginGenerator
  10. * @extends {Generator}
  11. */
  12. const PluginGenerator = webpackGenerator(
  13. [
  14. {
  15. type: "input",
  16. name: "name",
  17. message: "Plugin name",
  18. default: "my-webpack-plugin",
  19. filter: _.kebabCase,
  20. validate: str => str.length > 0
  21. }
  22. ],
  23. path.resolve(__dirname, "..", "generate-plugin"),
  24. [
  25. "src/cjs.js.tpl",
  26. "test/test-utils.js.tpl",
  27. "test/functional.test.js.tpl",
  28. "examples/simple/src/index.js.tpl",
  29. "examples/simple/src/lazy-module.js.tpl",
  30. "examples/simple/src/static-esm-module.js.tpl"
  31. ],
  32. ["src/_index.js.tpl", "examples/simple/_webpack.config.js.tpl"],
  33. gen => ({ name: _.upperFirst(_.camelCase(gen.props.name)) })
  34. );
  35. module.exports = {
  36. PluginGenerator
  37. };