Reputation: 1833
I created a web application in VS2017 (ASP.NET MVC Core, .NET 4.6) and installed web pack extension for visual studio
webpack.config.js:
"use strict"
{
// Required to form a complete output path
let path = require('path');
var webpack = require('webpack');
// Plugin for cleaning up the output folder (bundle) before creating a new one
const CleanWebpackPlugin = require('clean-webpack-plugin');
// Path to the output folder
const bundleFolder = "wwwroot/bundle/";
module.exports = {
// Application entry point
entry: "./app/main.ts",
// Output file
output: {
filename: 'script.js',
path: path.resolve(__dirname, bundleFolder)
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader"
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
root: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules')
]
},
plugins: [
new CleanWebpackPlugin([bundleFolder]),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
'window.$': 'jquery',
})
],
// Include the generation of debugging information within the output file
// (Required for debugging client scripts)
devtool: "inline-source-map"
};
}
jquery resides in ./node_modules
I expected to see a bundled jquery code in script.js but it isn't there
Upvotes: 0
Views: 123
Reputation: 12711
I don't believe webpack will bundle it unless you're actually using it somewhere. Try adding something like this to your entry point (or a module that it imports):
console.log('jquery version:', jQuery.fn.jquery);
That should get webpack to add it to your bundle.
Upvotes: 1