https://github.com/zhex/page-webpack-plugin
replace assets in webpages with compiled asset path
https://github.com/zhex/page-webpack-plugin
Last synced: 12 months ago
JSON representation
replace assets in webpages with compiled asset path
- Host: GitHub
- URL: https://github.com/zhex/page-webpack-plugin
- Owner: zhex
- Created: 2015-12-14T09:41:22.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-05-09T09:32:44.000Z (about 9 years ago)
- Last Synced: 2024-04-26T22:43:52.147Z (about 2 years ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# page-webpack-plugin
Webpack is awesome, but it is not webpages friendly. it using javascript file as the entry to handle all the staffs.This plugin give you the ability to handle your webpages separately. It copy all the webpages your want to the output path, and all assets links are replaced with the webpack compiled version.
```javascript
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var PagePlugin = require('page-webpack-plugin');
var glob = require('glob');
var path = require('path');
var cwd = process.cwd();
var entries = {};
glob.sync('**/entry_*.js', {root: './src/js'}).forEach(function (f) {
var name = path.relative(cwd + '/src/js', f).replace(/\.js$/, '');
entries[name] = path.resolve(f);
});
module.exports = {
entry: entries,
output: {
path: 'dist',
publicPath: '/app/',
filename: 'assets/[name].[chunkhash:8].js',
chunkFilename: 'assets/[name].[chunkhash:8].js'
},
module: {
loaders: [
{ test: /\.(jpe?g|png|gif|svg)$/i, loaders: [
'image?{bypassOnDebug: true, progressive:true, optimizationLevel: 3, pngquant:{quality: "65-80", speed: 4}}',
'url?limit=100&name=assets/img/[name].[hash:8].[ext]'
]},
{
test: /\.less$/,
loader: ExtractTextPlugin.extract('style', 'css!less')
},
{
test: /\.html$/,
loader: 'html'
}
]
},
plugins: [
new ExtractTextPlugin('assets/[name].[contenthash:8].css', { allChunks: true }),
new PagePlugin({
cwd: __dirname + '/src',
files: '**/*.html',
outputPageName: function (filename) {
return filename;
},
entryName: function (name) {
return name;
}
})
]
};
```