G
G
Gagatyn2018-07-13 18:39:06
JavaScript
Gagatyn, 2018-07-13 18:39:06

Why didn't the html page output when building the gulp package?

source/app.js folder

import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render(
    <h1>
        Hello <b>React</b>!
    </h1>,
    document.getElementById("app")
)

gulpfile.js
gulp.task('babelJSX', function() { // для транспиляции jsx
    return gulp.src('js/source/**/*.js')
        .pipe(babel({
            plugins: ['transform-react-jsx']
        }))
        .pipe(gulp.dest('js/build'))
});

gulp.task('babel', function() { // для es2015
    return gulp.src('js/build/**/*.js')
        .pipe(babel({ presets: ["@babel/preset-env", "@babel/preset-react"] }))
        .pipe(gulp.dest('js/build'))
});

gulp.task('browserify', function() { // создание одного пакета bundel.js
    return gulp.src('js/build/**/*.js')
        .pipe(browserify({
            transform: ['es6ify'],
            extensions: ['.js']
        }))
        .pipe(rename('bundle.js'))
        .pipe(gulp.dest('./'))
});

gulp.task('concat', function() { // bundle.css
    return gulp.src('css/**/*.css')
        .pipe(concat('bundle.css'))
        .pipe(gulp.dest('./'));
});

I run :
1. gulp babelJSX
2. gulp babel
3. gulp browserify
4. gulp concat
Everything worked, but the html is empty. A lot of things compiled in bundle.js, it doesn't even have a line Helloor getElementById('app'). Tell me what is the error, maybe use some analogue of browserify?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question