Gpack与Webpack-Stream获取" jQuery未定义"在尝试使用Bootstrap时

时间:2017-09-07 15:22:55

标签: webpack gulp webpack-2

我似乎在我的网站的控制台中收到错误" jQuery未定义"我认为问题与Webpack和Gulp有关。

我的档案:

Gulpfile

import webpack from 'webpack';
import WebpackStream from 'webpack-stream';
import WebpackConfig from './webpack.config.babel.js';

var build = {
    live: '../TheICC.Site/assets',
    dev: 'html/assets',
    cshtml: '../TheICC.Site'
}

gulp.task( 'js', function() {

    gulp.src( 'js/*.js' )
        .pipe( $.wait(500) )
        .pipe( WebpackStream({}, webpack ))
        .pipe( WebpackStream( WebpackConfig ))
        .pipe( gulp.dest( build.dev + '/js' ) )
        .pipe( gulp.dest( build.live + '/js' ) )

} );

Webpack文件

import path from 'path';
import webpack from 'webpack';

const BUILD_DIR = path.resolve(__dirname, './html/assets/js')

module.exports = {
    cache: true,
    entry: './js/app.js',
    output: {
        path: BUILD_DIR,
        filename: 'script.bundle.js'
    },
    plugins: [
        new webpack.ProvidePlugin({
            $: 'jquery',
            jQuery: 'jquery',
            'window.jQuery': 'jquery',
            // In case you imported plugins individually, you must also require them here:
            Util: 'exports-loader?Util!js/bootstrap/util',
            Modal: 'exports-loader?Modal!js/bootstrap/modal',
        }),
    ],
    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader'
            }
        ]
    }
};

我已经看过Webpackstream issues with babel-loader,甚至在页面上跟source,但由于某种原因,我仍然在控制台中收到未定义的错误。

我在控制台中没有出错,而且正在正确编译

0 个答案:

没有答案