Skip to content

Instantly share code, notes, and snippets.

var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: ['./src/index.js'],
output: {
path: __dirname + '/dist',
filename: './bundle.js'
},
module: {
<!DOCTYPE html>
<html>
<head>
<title>Webpack test</title>
</head>
<body>
</body>
</html>
mkdir new-project
cd new-project
npm init
npm install webpack --global
npm install webpack --save-dev
module.exports = "Hello Webpack!";
var print = require('./print.js');
document.write(print);
webpack index.js bundle.js
<!DOCTYPE html>
<html>
<head>
<title>Webpack test</title>
<script type="text/javascript" src="./bundle.js"></script>
</head>
<body>
</body>
</html>
module.exports = {
entry: ['./index.js'],
output: {
filename: './bundle.js'
}
};
dist/
src/
index.js
print.js
style.css
index.html
package.json
webpack.config.js