I have a basic ReactJS application. I use webpack and want to use modules from the gazebo. I installed bower-webpack-plugin and added the jquery library to bower.
webpack.config.js
var BowerWebpackPlugin = require("bower-webpack-plugin"); var webpack = require("webpack"); module.exports = { entry: './index.jsx', output: { filename: 'bundle.js', publicPath: 'http://localhost:8090/assets' }, module: { loaders: [ { //tell webpack to use jsx-loader for all *.jsx files test: /\.jsx$/, loader: 'jsx-loader?insertPragma=React.DOM&harmony' } ] }, plugins: [ new BowerWebpackPlugin(), new webpack.ProvidePlugin({ $: 'jquery', }) ], externals: { //don't bundle the 'react' npm package with our bundle.js //but get it from a global 'React' variable 'react': 'React' }, resolve: { extensions: ['', '.js', '.jsx'], alias: { jquery: "./bower_components/jquery/dist/jquery.js" } } }
Edit: I am now using this webpack configuration with bauer dependencies and without bower-webpack-plugin
bower.json
{ "name": "jquery", "version": "2.1.4", "main": "dist/jquery.js", "license": "MIT", "ignore": [ "**/.*", "build", "dist/cdn", "speed", "test", "*.md", "AUTHORS.txt", "Gruntfile.js", "package.json" ], "devDependencies": { "sizzle": "2.1.1-jquery.2.1.2", "requirejs": "2.1.10", "qunit": "1.14.0", "sinon": "1.8.1" }, "keywords": [ "jquery", "javascript", "library" ] }
index.html
<!DOCTYPE html> <html> <head> <title>Basic Property Grid</title> <script src="./node_modules/react/dist/react-with-addons.js"></script> </head> <body> <div id="content"> </div> <script src="http://localhost:8090/webpack-dev-server.js"></script> <script type="text/javascript" src="http://localhost:8090/assets/bundle.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("body").append("This is Hello World by JQuery"); }); </script> </body> </html>
When I open the main page, I get an error message: "$ not defined".
project structure
