From 99b8fcec6c91383750fd7c86e077e70c2b4b1103 Mon Sep 17 00:00:00 2001 From: Edinei Cavalcanti Date: Sat, 20 Jun 2020 20:38:19 -0300 Subject: [PATCH] Use html-webpack-template --- config/webpack.common.js | 35 ++++++++++++++----- package.json | 1 + src/shared/head.html | 72 ++++++++++++++++++++++++++++++++++++++++ yarn.lock | 5 +++ 4 files changed, 105 insertions(+), 8 deletions(-) create mode 100644 src/shared/head.html diff --git a/config/webpack.common.js b/config/webpack.common.js index fb24761a..1d232869 100644 --- a/config/webpack.common.js +++ b/config/webpack.common.js @@ -7,6 +7,18 @@ const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin') const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin') const StyleExtHtmlWebpackPlugin = require('style-ext-html-webpack-plugin') +const fs = require('fs') +const filePath = path.join(__dirname, '../src/shared/head.html') +let head = '' + +fs.readFile(filePath, { encoding: 'utf-8' }, function (err, data) { + if (!err) { + head = data + } else { + console.log(err) + } +}) + const minifyOptions = { html5: true, collapseWhitespace: true, @@ -26,17 +38,24 @@ const minifyOptions = { const title = 'Edinei Cavalcanti' const HtmlWebpackPluginConfigIndex = new HtmlWebpackPlugin({ - template: path.join(__dirname, '../src/index.html'), + inject: false, + template: require('html-webpack-template'), filename: 'index.html', minify: minifyOptions, title, - keywords: `neiesc,Edinei,developer,desenvolvedor,programador,programmer, - dotnet,dotnetcore,csharp,nodejs,python`, - description: `Olá sou Edinei aka neiesc. - Começei profissionalmente em 2010 minha carreira, sólido conhecimente em TI, - mais especificamente em desenvolvimento de software em C#, .NET, .NET Core, Node.js e Python - com experiência em grandes aplicações.`, - author: 'Edinei aka neiesc' + meta: [ + { + name: 'keywords', + content: `neiesc,Edinei,developer,desenvolvedor,programador,programmer, + dotnet,dotnetcore,csharp,nodejs,python` + }, + { + name: 'author', + content: 'Edinei aka neiesc' + } + ], + headHtmlSnippet: head, + bodyHtmlSnippet: 'teste' }) const HtmlWebpackPluginConfigPalestras = new HtmlWebpackPlugin({ diff --git a/package.json b/package.json index 67969fc0..e1ce9c19 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "eslint-plugin-standard": "^4.0.1", "html-loader": "^1.1.0", "html-webpack-plugin": "^4.3.0", + "html-webpack-template": "^6.2.0", "mini-css-extract-plugin": "^0.9.0", "optimize-css-assets-webpack-plugin": "^5.0.3", "prettier": "^2.0.5", diff --git a/src/shared/head.html b/src/shared/head.html new file mode 100644 index 00000000..a1c22be5 --- /dev/null +++ b/src/shared/head.html @@ -0,0 +1,72 @@ + + + <%=htmlWebpackPlugin.options.title%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/yarn.lock b/yarn.lock index 988103a7..4fffd985 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3625,6 +3625,11 @@ html-webpack-plugin@^4.3.0: tapable "^1.1.3" util.promisify "1.0.0" +html-webpack-template@^6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/html-webpack-template/-/html-webpack-template-6.2.0.tgz#3c9f15f616f4500927909d34adfbccb20d37943c" + integrity sha512-wyzIjbe9yXGyQ6yAeFjWmku7YOlW85w1dxqLnAQ564uRNNoBhpZVTQl7ouROoyQrfZUSoPUJiw7oWn31NDiuQQ== + htmlparser2@^3.3.0: version "3.10.1" resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.10.1.tgz#bd679dc3f59897b6a34bb10749c855bb53a9392f"