Webpack vs gulp-webpack

时间:2017-12-20 18:16:32

标签: webpack gulp gulp-webpack

我正在尝试从gulp任务webpack来处理包含.js文件的目录。我正在使用gulp-webpack 1.5.0。 Gulp任务定义为:

return gulp.src(joinPath(config.aliasify.dest, 'index.js'))
            .pipe(webpack( require('./_____webpack.config.js') ))
            .pipe(gulp.dest('dist/'));

_____ webpack.config.js是:

var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');

module.exports = {
    stats: {
        // Configure the console output
        errorDetails: true,
        colors: true,
        modules: true,
        reasons: true
    },
    progress: true,
    entry: "./out/js/index.js",
    output: {
        filename: "bundle.js",
        path: __dirname + "/dist"
    }

}

悲惨地失败了。 JSON文件似乎有问题:

  错误在./~/aws-sdk/apis/cognito-idp-2016-04-18.paginators.json   模块解析失败:/Users/omatrot/Projects/trash/reactxp/samples/hello-world/node_modules/aws-sdk/apis/cognito-idp-2016-04-18.paginators.json意外的令牌(2:14)   您可能需要适当的加载程序来处理此文件类型。   SyntaxError:意外的令牌(2:14)

使用明显相同的配置在同一目录上运行webpack可以正常工作。

webpack.config.ts file is:

import * as webpack from 'webpack';

const config: webpack.Configuration = {
    entry: "./out/js/index.js",
    output: {
        filename: "bundle.js",
        path: __dirname + "/dist"
    },

};

export default config;
  

webpack --display-error-details --progress --colors

     

哈希:0a378df14f58624d244f   版本:webpack 2.2.1   时间:3920ms           资产大小块大块名称       bundle.js 3.07 MB 0 [emit] [big] main   bundle.js.map 3.71 MB 0 [emit] main      [8] ./~/reactxp/index.js 146字节{0} [已建]    [112] ./out/js/ExercisesStore.js 3.29 kB {0} [built]    [120] ./~/amazon-cognito-identity-js/es/CognitoRefreshToken.js 1.4 kB {0} [built]    [126] ./~/amazon-cognito-identity-js/es/index.js 1.58 kB {0} [built]    [217] ./out/js/App3.js 14.4 kB {0} [built]    [278] ./~/jwt-decode/lib/index.js 680字节{0} [已建]    [490] ./out/js/AlertAndPromptWeb.js 3.4 kB {0} [built]    [494] ./out/js/EditExerciseAttributePropertiesPanel.js 10.4 kB {0} [built]    [495] ./out/js/EditExerciseAttributesValuesPanel.js 9.4 kB {0} [built]    [496] ./out/js/EditExerciseCategoryPropertiesPanel.js 5.78 kB {0} [built]    [497] ./out/js/EditExerciseMainPropertiesPanel.js 4.91 kB {0} [built]    [498] ./out/js/ExercicesTopLevelView.js 13.7 kB {0} [built]    [502] ./out/js/LogHelper.js 791字节{0} [已建]    [504] ./out/js/asynccognito.js 2.08 kB {0} [built]    [505] ./out/js/index.js 599字节{0} [已建]       + 491个隐藏模块

我做错了,但我找不到它是什么。

任何帮助表示感谢。

1 个答案:

答案 0 :(得分:2)

好的,在重新安装节点模块的过程中,我收到了一条警告信息,让我得出一个解决方案:

  

npm WARN已弃用gulp-webpack@1.5.0:已重命名为https://www.npmjs.com/package/webpack-stream

所以我切换到这个模块,在删除不推荐使用的进度配置选项后立即工作。