Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将前端javascript文件包含到捆绑Web包中_Javascript_Node.js_Express_Webpack_Webpack 2 - Fatal编程技术网

如何将前端javascript文件包含到捆绑Web包中

如何将前端javascript文件包含到捆绑Web包中,javascript,node.js,express,webpack,webpack-2,Javascript,Node.js,Express,Webpack,Webpack 2,我需要将前端javascript文件绑定到bundle.js。 这是我的webpack.config文件 var path = require('path'); var nodeExternals = require('webpack-node-externals'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const ExtractTextPlu

我需要将前端javascript文件绑定到bundle.js。 这是我的webpack.config文件

var path = require('path');
var nodeExternals = require('webpack-node-externals');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
    target: 'node',
    entry:['babel-polyfill', './bin/run.js'],
    output: {
        path: './build',
        filename: '[name].min.js'
    },
    externals: nodeModules,
    plugins: [
        new HtmlWebpackPlugin(),
        new webpack.optimize.UglifyJsPlugin({
            compressor: {
                warnings: false,
                screw_ie8: true
            }
        })
    ],
    module: {
        loaders: [
            {
                loader: 'babel-loader',
                test: /\.js$/,
                include:/public/,
                exclude: /(node_modules|bower_components)/
            }
        ],
        noParse: [/ws/]
    }
};

如何将前端javascript文件包含到捆绑包中?

如果您使用的是
webpack2
,那么您应该知道此更改:

module: {
    rules: [ // <----it is been changed to "rules"
        {
            test: /\.js$/,
            loader: 'babel-loader',
            exclude: /(node_modules|bower_components)/
        }
    ],
    noParse: [/ws/]
}
模块:{

规则:[//网页包配置不是指定完整文件列表的地方。在您的输入脚本
/bin/run.js
中,您需要
要求
导入
其他文件(并让这些文件类似于其他文件等,以形成依赖关系树)。网页包的选项记录在“概念”下–and.got it...@JonathanLonowski thanksnow我在jquery中有错误,`F:\master QMS-Copy\QMS\node\u modules\jquery\dist\jquery.js:31抛出新错误(“jquery需要一个包含文档的窗口”);^错误:jQuery需要一个窗口,其中包含一个文档“我用”new webpack.ProvidePlugin({$:'jQuery',jQuery:'jQuery','window.jQuery':'jQuery'}),“此块,不使用@JonathanLonowski