mirror of
https://github.com/Febbweiss/springboot-react-webpack.git
synced 2026-03-04 22:25:34 +00:00
Optim: populate html template with resource links and hash
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
var path = require('path'),
|
||||
webpack = require('webpack'),
|
||||
CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"),
|
||||
ExtractTextPlugin = require("extract-text-webpack-plugin");
|
||||
ExtractTextPlugin = require("extract-text-webpack-plugin"),
|
||||
HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
|
||||
var source_dir = __dirname + '/src/main/resources/static/js',
|
||||
var source_dir = __dirname + '/src/main/resources/static',
|
||||
node_dir = __dirname + '/node_modules';
|
||||
|
||||
var config = {
|
||||
entry: {
|
||||
app: [source_dir + '/app.render'],
|
||||
vendors: [source_dir + '/vendors']
|
||||
app: [source_dir + '/js/app.render'],
|
||||
vendors: [source_dir + '/js/vendors']
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['', '.js', '.jsx', '.css']
|
||||
@@ -18,12 +19,19 @@ var config = {
|
||||
cache: true,
|
||||
debug: true,
|
||||
output: {
|
||||
path: './target/classes/static/js',
|
||||
filename: '[name].bundle.js'
|
||||
path: './target/classes/static',
|
||||
filename: 'js/[name].bundle.js',
|
||||
publicPath: '/'
|
||||
},
|
||||
plugins: [
|
||||
new ExtractTextPlugin("../css/[name].css"),
|
||||
new ExtractTextPlugin("css/[name].css"),
|
||||
new CommonsChunkPlugin("vendors", null, true),
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.join(__dirname, 'src/main/resources/templates/index-template.html'),
|
||||
filename: '../templates/index.html',
|
||||
xhtml: true,
|
||||
hash: true
|
||||
})
|
||||
],
|
||||
module: {
|
||||
loaders: [
|
||||
@@ -42,24 +50,31 @@ var config = {
|
||||
},
|
||||
{
|
||||
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
|
||||
loader: "file?name=../css/[name].[ext]"
|
||||
loader: "file?name=font/[name].[ext]"
|
||||
},
|
||||
{
|
||||
test: /\.(woff|woff2)$/,
|
||||
loader:"url?prefix=font/&limit=5000&name=../css/[name].[ext]"
|
||||
loader:"url?prefix=font/&limit=5000&name=font/[name].[ext]"
|
||||
},
|
||||
{
|
||||
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
|
||||
loader: "url?limit=10000&mimetype=application/octet-stream&&name=../css/[name].[ext]"
|
||||
loader: "url?limit=10000&mimetype=application/octet-stream&&name=font/[name].[ext]"
|
||||
},
|
||||
{
|
||||
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
|
||||
loader: "url?limit=10000&mimetype=image/svg+xml&&name=../css/[name].[ext]"
|
||||
loader: "url?limit=10000&mimetype=image/svg+xml&&name=font/[name].[ext]"
|
||||
},
|
||||
{
|
||||
test: /\.html$/,
|
||||
loader: 'html-loader?minimize=false'
|
||||
}
|
||||
]
|
||||
},
|
||||
postcss: function () {
|
||||
return [];
|
||||
},
|
||||
htmlLoader: {
|
||||
removeAttributeQuotes: false,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user