Inline css twice in Vue-CLI 3 with html-webpack-inline-source-plugin
See original GitHub issueExpected behavior
Size of my css file is 13.8kb, html is 2.8kb. So I wanna that my css file can be inlined with html-webpack-inline-source-plugin.
Current behavior
The size of my html file increased to 30.4kb And I found that my css file was inlined twice.
Config
Adding this plugin by webpack-chain API
// vue.config.js
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin')
module.exports = {
chainWebpack: config => {
config.plugin('html').tap(args => {
args[0].inlineSource = '.css$'
return args
}
config.plugin('inline').use(HtmlWebpackInlineSourcePlugin)
}
}
When I inspecting my project’s webpack config vue inspect > output.js
// output.js
/* config.plugin('html') */
new HtmlWebpackPlugin(
{
templateParameters: function () { /* omitted long function */ },
template: '/Users/logan/tencent/qgact/src/index.html',
filename: 'index.html',
inlineSource: '.css$'
}
),
/* config.plugin('inline') */
new HtmlWebpackInlineSourcePlugin()
Enviroment
Node.js 10.9.0
@vue/cli-service 3.0.0
webpack 4.15.1
html-webpack-plugin 3.2.0
html-webpack-inline-source-plugin 0.0.10
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Inline JavaScript and CSS with webpack - Stack Overflow
I'm using Webpack for bundling resources. Currently it bundle both the CSS and JS files into a separate file called bundle. js. How...
Read more >Working with CSS | Vue CLI
Working with CSS #. Vue CLI projects come with support for PostCSS, CSS Modules and pre-processors including Sass, Less and Stylus.
Read more >html-inline-css-webpack-plugin - npm
A webpack plugin for convert external stylesheet to embedded stylesheet, aka document stylesheet. Latest version: 1.11.1, last published: 2 ...
Read more >Common mistakes to avoid while working with Vue.js
The first thing to do in order to use Vue.js is to import it. If you follow the official guide and use an...
Read more >Writing multiple Vue components in a single file
Vue CLI 3 +; Vue CLI < 3.0 ... Your Vue.js App"/> </div> </template> <script> import Vue from 'vue'; // inline component with...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Vue-cli 3 would use @vue/preload-webpack-plugin to auto add preload link tag to your html like this
<link href=js/app.js rel=preload as=script>
<link href=css/app.css rel=preload as=style>
,you can modify this plugin’s config in vue.config.js(if you don’t have this file, create it in your project’s root folder)
If it works, let me know.
how you have since resolved this issue? 😃