Hello world!
webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackPartialsPlugin = require('../../');
module.exports = {
entry: {
main: path.join(__dirname, './main.js')
},
output: {
path: path.join(__dirname, './dist'),
filename: '[name].js'
},
plugins: [
new HtmlWebpackPlugin(),
new HtmlWebpackPartialsPlugin([
{
path: path.join(__dirname, './partials/head.html'),
location: 'head',
priority: 'high',
options: {
// Note: Update this to your property ID
ga_property_id: 'UA-28076707-7'
}
},
{
path: path.join(__dirname, './partials/body.html')
}
])
]
};
main.js
console.log('Test!');
partials/body.html
<h1>Hello world!</h1>
...and the rest of this configuration example
partials/head.html
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= ga_property_id %>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<%= ga_property_id %>');
</script>