D
D
DenJel2015-09-09 16:02:48
Programming
DenJel, 2015-09-09 16:02:48

How and on what to write a plugin/module?

Hello
There is a component with the following structure (simplified):

-component(folder)
    -icons(folder)
    -component.jsx
    -component.scss

in jsx basic markup:
import React from 'react';
import css from './component.scss';


class Component extends React.Component{
  render(){

    return(
        <div className={css.root}>
          
        </div>
      );
  }

}

export default Component;

How and on what to implement something (plugin, module) that automatically generates such a component with all the files, directories and dependencies in the files, so that I just enter generate name into the console and it creates a ready-made component with this name. webpack builder.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Taratin, 2015-09-09
@DenJel

An ordinary batch file can do just fine.
An example of generating a basic gulp project for me
gulpbase.bat

spoiler
@ECHO OFF
>package.json  echo {
>>package.json echo     "name": "npm_package",
>>package.json echo     "version": "1.0.0",
>>package.json echo     "main": "index.js",
>>package.json echo     "author": "",
>>package.json echo     "license": "ISC",
>>package.json echo     "devDependencies": {
>>package.json echo     "gulp": "*",
>>package.json echo     "gulp-concat": "*",
>>package.json echo     "gulp-minify-css": "*",
>>package.json echo     "gulp-uglify": "*",
>>package.json echo     "gulp-html-replace": "*"
>>package.json echo     }
>>package.json echo }


>gulpfile.js echo var gulp = require('gulp'),
>>gulpfile.js echo     minifyCSS = require('gulp-minify-css'),  // Минификация CSS
>>gulpfile.js echo     uglify = require('gulp-uglify'), // Минификация JS
>>gulpfile.js echo     concat = require('gulp-concat'); // Склейка файлов
>>gulpfile.js echo     htmlreplace = require('gulp-html-replace')
>>gulpfile.js echo.
>>gulpfile.js echo.
>>gulpfile.js echo gulp.task('html', function() {
>>gulpfile.js echo     gulp.src(['../index.html'])
>>gulpfile.js echo         .pipe(htmlreplace({
>>gulpfile.js echo             'css': ['css/main.min.css'],
>>gulpfile.js echo             'js': ['//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', '//cdnjs.cloudflare.com/ajax/libs/three.js/r71/three.min.js', 'js/main.min.js]'
>>gulpfile.js echo         }))
>>gulpfile.js echo         .pipe(gulp.dest('dist/'));
>>gulpfile.js echo });
>>gulpfile.js echo.
>>gulpfile.js echo gulp.task('css', function() {
>>gulpfile.js echo     return gulp.src(['../normalize.css', '../main.css'])
>>gulpfile.js echo         .pipe(concat('main.css'))
>>gulpfile.js echo         .pipe(minifyCSS({
>>gulpfile.js echo             compatibility: 'ie8'
>>gulpfile.js echo         }))
>>gulpfile.js echo         .pipe(gulp.dest('build/css'))
>>gulpfile.js echo });
>>gulpfile.js echo.
>>gulpfile.js echo gulp.task('js', function() {
>>gulpfile.js echo     return gulp.src(['../main.js'])
>>gulpfile.js echo         .pipe(concat('main.js'))
>>gulpfile.js echo         .pipe(uglify())
>>gulpfile.js echo         .pipe(gulp.dest('build/js'))
>>gulpfile.js echo });
>>gulpfile.js echo.
>>gulpfile.js echo.
>>gulpfile.js echo gulp.task('default', ['css', 'js', 'html']);

gulpupdate.bat

+
https://stackoverflow.com/questions/4165387/create...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question