Skip to content

Instantly share code, notes, and snippets.

@misterdev
Last active March 21, 2019 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misterdev/a6cfa1042092cd0a54b52ce3030959d3 to your computer and use it in GitHub Desktop.
Save misterdev/a6cfa1042092cd0a54b52ce3030959d3 to your computer and use it in GitHub Desktop.
6
const Generator = require('yeoman-generator');
const { List, Input, InputValidate } = require('@webpack-cli/webpack-scaffold');
// => Import our webpack config generator
const createWebpackConfig = require('./config/webpack');
module.exports = class WebpackGenerator extends Generator {
/* ... */
prompting() {
return this.prompt([ /* ... */ ]).then (answers => {
this.answers = answers;
/* ... */
this.options.env.configuration.dev = {
// => This add the plugins imports at the beginning of our generated webpack.config.js
topScope = [
"const HtmlWebpackPlugin = require('html-webpack-plugin')",
"const CopyWebpackPlugin = require('copy-webpack-plugin')",
"const VueLoaderPlugin = require('vue-loader/lib/plugin')"
],
// => This generates a configuration using the user preferences
webpackOptions: createWebpackConfig(this.answers)
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment