Created
December 18, 2016 23:24
-
-
Save eloytoro/576f72c11caa5df6c0613f0bb4083e43 to your computer and use it in GitHub Desktop.
Compile HTML so everything's inlined
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const HtmlPlugin = require('html-webpack-plugin'); | |
const path = require('path') | |
// webpack.config.js | |
module.exports = { | |
output: { | |
path: './build', // This is where images AND js will go | |
publicPath: '/', | |
filename: '[name].html' | |
}, | |
plugins: fs.readdirSync('./htmls').map(file => { | |
return new HtmlPlugin({ | |
template: `./htmls/${file}`, | |
filename: file, | |
inject: true | |
}) | |
}), | |
module: { | |
loaders: [ | |
{ test: /\.css$/, loader: 'css-loader' }, | |
{ test: /\.html/, loader: 'html-loader?attrs=link:href script:src img:src' }, | |
{ test: /\.(png|jpg|ttf|eot|svg|woff(2)?)$/, loader: 'url-loader' } // inline base64 URLs for <=8k images, direct URLs for the rest | |
] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
input
output