Замена задания gulp скриптом npm - PullRequest
0 голосов
/ 27 января 2020

У меня в gulpfile есть задание gulp. js следующим образом:

gulp.task('build', function() {
let webPath = './webpack.config.dev.js';

if (process.env.var) {
    webpackConfigPath = './webpack.config.' + process.env.var + '.js';
}

const webCon = require(webPath);

return gulp.src('/js/index.js')
    .pipe(webpackStream(webCon, require("webpack")))
    .pipe(gulp.dest(BUILD_PATH));});

Чтобы заменить это и избавиться от зависимости от gulp, я использую пакет fs-extra и написал работает следующим образом:

function buildApp() {
        let webPath = '/webpack.config.dev.js';
        if (process.env.var) {
            webpath = '/webpack.config.' + process.env.var + '.js';
        }
        const webCon= require(webpackConfigPath);

        let readStr = fs.createReadStream('/ui/js/index.js');
        let writeStr = fs.createWriteStream('/src/main/resources/public/app.js');

        readStr.pipe(webpackStream(webpackConfig, require("webpack")))
            .pipe(writeStr);
}

Однако, это выдает ошибку, которая говорит

TypeError: file.isNull is not a function
    at Stream.<anonymous> (path\node_modules\webpack-stream\index.js:95:14)
    at Stream.stream.write (path\node_modules\through\index.js:26:11)
    at ReadStream.ondata (_stream_readable.js:727:22)
    at ReadStream.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at ReadStream.Readable.push (_stream_readable.js:224:10)
    at internal/fs/streams.js:191:12
    at FSReqCallback.wrapper [as oncomplete] (fs.js:470:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! esg-scoring-model@0.0.1 build: `node build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the esg-scoring-model@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     path\AppData\Roaming\npm-cache\_logs\2020-01-27T20_31_56_858Z-debug.log

Есть предложения?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...