Output Management

This commit is contained in:
Joe
2018-06-28 12:19:48 -05:00
parent 83c9051ace
commit b10be0ca77
5 changed files with 21 additions and 4 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/node_modules
/dist
!/dist/index.html

5
dist/index.html vendored
View File

@@ -1,9 +1,10 @@
<!doctype html>
<html>
<head>
<title>Getting Started</title>
<title>Output Management</title>
<script src="./print.bundle.js"></script>
</head>
<body>
<script src="main.js"></script>
<script src="./app.bundle.js"></script>
</body>
</html>

View File

@@ -1,11 +1,18 @@
import _ from 'lodash';
import printMe from './print.js';
function component() {
var element = document.createElement('div');
var btn =document.createElement('button');
// Lodash, now imported by this script
element.innerHTML = _.join(['Hello', 'webpack'], ' ');
btn.innerHTML = 'Click me and check the console!';
btn.onclick= printMe;
element.appendChild(btn);
return element;
}

3
src/print.js Normal file
View File

@@ -0,0 +1,3 @@
export default function printMe() {
console.log('I get called from print.js!');
}

View File

@@ -1,9 +1,12 @@
const path = require('path');
module.exports = {
entry: './src/index.js',
entry: {
app: './src/index.js',
print: './src/print.js'
},
output: {
filename: 'main.js',
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
}
};