[英]how to include frontend javascript files to bundle webpack
I need to bundle my front-end javascript files to bundle.js. 我需要将前端javascript文件捆绑到bundle.js。 here is my webpack.config file,
这是我的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/]
}
};
how can I include my front-end javascript files to the bundle ? 如何将我的前端javascript文件包含到捆绑包中?
If you are using webpack2
then you should know this change: 如果您使用的是
webpack2
则应该知道此更改:
module: {
rules: [ // <----it is been changed to "rules"
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/
}
],
noParse: [/ws/]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.