Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# understanding_webpack
# Example for [Webpack Tutorial: Understanding How it Works](https://www.ag-grid.com/ag-grid-understanding-webpack/)

## To make this example work
You will need `Node.js` (https://nodejs.org/en/) installed.
`npm` is package manager for it.

1) `git clone https://github.com/seanlandsman/ag-grid-understanding-webpack.git`
2) `cd ag-grid-understanding-webpack`
3) `npm install` installs packages listed in `packages.json`, so Webpack can use or bundle them.
4) `node_modules/webpack/bin/webpack.js` will let Webpack do it's work

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@
"babel-loader": "^6.2.10",
"babel-preset-es2015": "^6.18.0",
"css-loader": "^0.26.1",
"expose-loader": "^0.7.3",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.11.2",
"html-webpack-plugin": "2.26.x",
"image-webpack-loader": "^3.4.2",
"rimraf": "2.5.4",
"style-loader": "^0.13.1",
"url-loader": "^0.5.9",
"webpack": "1.14.0",
"webpack-dev-server": "1.16.2"
}
Expand Down
8 changes: 7 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ addImageToPage(multiplyImg);
document.body.appendChild(multiplyResultsSpan);

addImageToPage(sumImg);
document.body.appendChild(sumResultSpan);
document.body.appendChild(sumResultSpan);

require("jquery");
//import jQuery from 'jquery'; as it seems no import is needed?!
$(document).ready(function() {
$('body').css("background-color", "red");
});
26 changes: 20 additions & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
Expand All @@ -23,15 +24,28 @@ module.exports = {
loader: ExtractTextPlugin.extract('css-loader')
},
{
test: /\.png$/,
loaders: [
'url-loader?limit=5000',
'image-webpack-loader'
]
}
test: /\.(jpe?g|png|gif|svg)$/i,
loader: "file-loader?name=icons/[module]/[name].[ext]"
// i. e. file?name=[path][name].[ext]&context=/the/root/path
// This copies the file /the/root/path/dir/file.png to /output-directory/dir/file.png.

// loaders: [

// 'url-loader?limit=5000',
// 'image-webpack-loader'
// ]
},
{ test: require.resolve('jquery'), loader: 'expose?jQuery!expose?$' }
]
},
plugins: [
new ExtractTextPlugin('style.css')
// new webpack.ProvidePlugin({
// '$': 'jquery',
// 'jquery': 'jquery',
// 'jQuery': 'jquery',
// 'window.$': 'jquery',
// 'window.jQuery': 'jquery' // jQuery pluginy no ... ¯\_(ツ)_/¯
// }),
]
};