Last active
March 21, 2019 17:01
-
-
Save misterdev/b4c320f7ab730ffeb5ca13c8e1172811 to your computer and use it in GitHub Desktop.
8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (answers) => { | |
const { name, entry, inFolder: src } = answers; | |
return ({ | |
"name": name, | |
"version": "1.0.0", | |
"main": `${src}/${entry}.js`, | |
"license": "MIT", | |
"scripts": { | |
"serve": "webpack-dev-server --mode development --progress --hot --open", | |
"build": "webpack --mode production --progress", | |
"lint": `eslint ${src}/*.{js,vue} ${src}/**/*.{js,vue}`, | |
"lint:fix": `eslint --fix ${src}/*.{js,vue} ${src}/**/*.{js,vue}` | |
}, | |
"dependencies": { | |
"vue": "^2.6.9" | |
}, | |
"devDependencies": { | |
"@babel/core": "^7.3.4", | |
"@babel/preset-env": "^7.3.4", | |
"babel-eslint": "^10.0.1", | |
"babel-loader": "^8.0.5", | |
"copy-webpack-plugin": "^5.0.1", | |
"css-loader": "^2.1.1", | |
"eslint": "^5.15.2", | |
"eslint-config-airbnb-base": "^13.1.0", | |
"eslint-plugin-import": "^2.16.0", | |
"eslint-plugin-vue": "^5.2.2", | |
"file-loader": "^3.0.1", | |
"html-webpack-plugin": "^3.2.0", | |
"vue-loader": "^15.7.0", | |
"vue-template-compiler": "^2.6.9", | |
"webpack": "^4.29.6", | |
"webpack-cli": "^3.2.3", | |
"webpack-dev-server": "^3.2.1" | |
} | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ... */ | |
// => Every module exports a function returning a json configuration | |
const createPackageJson = require('./config/package-json'); | |
const createBabelrc = require('./config/babelrc'); | |
const createEslintrc = require('./config/eslintrc'); | |
module.exports = class WebpackGenerator extends Generator { | |
/* ... */ | |
writing() { | |
// => We write each json into the right file in the file system | |
this.fs.extendJSON(this.destinationPath('package.json'), createPackageJson(this.answers)); | |
// => We create also the configuration files for babel and eslint | |
this.fs.extendJSON(this.destinationPath('.babelrc'), createBabelrc()); | |
this.fs.extendJSON(this.destinationPath('.eslintrc'), createEslintrc()); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment