1656651600
vite's MPA unlike @vue/cli
's pages
option have a configuration in dev mode.
vite's html file need to place in project's root to have same behavior in dev and production mode, it makes your project's root dir looks chaotic.
And if you follow vite's MPA, put other file in other directory, unlike index.html
, you need useless middle directory(Ex. from vite's MPA doc http://localhost:3000/nested/nested.html
) to located it.
so, i write this plugin to make vite's MPA more configurable and in dev mode or production has same behavior.
this plugin use vite's configureServer
Hook to intercept html request and response the html content requested from browser.
0.2.9
add a new option injectCode
to add some code before/after tag in html file0.2.8
add a new option extraGlobPattern
to customize fast-glob
's pattern. Default pattern is ['**/*.html', '!node_modules/**/*.html', '!.**/*.html']
, attention: if your config has problems, such as you didn't ignore dist
, when build,it will occur error: new Error('[vite]: Rollup failed to resolve import "${id}" from "${importer}".\n'
0.2.6
pages
now correctly identify multi-level directories0.2.3
pages
options now can set to true to allow all html in project.0.2.1
now works fine with @vitejs/plugin-react
.0.2.0
has reworked, so config have a little changepage
's config renamed to template
page
can have a independent render
functiondata
, its' config will be covered by page
's data
pages
' will be treat as template file@vue/cli
's pages
)pages
.pages
options) under dist's sub-folder to dist folder, and then delete the rest html file.build.rollupOptions.input
from pagesyarn add vite-plugin-virtual-html --dev # npm install vite-plugin-virtual-html -D
Add it to vite.config.js
// vite.config.js
const virtualHtml = require('vite-plugin-virtual-html')
const pages = {
index: '/src/index/index.html',
login: '/src/login/login.html',
}
module.exports = {
plugins: [virtualHtml({
pages,
indexPage: 'login'
})],
}
config your project's all html/template file's path
it will be used for:
build.rollupOptions.input
template
and data
to render it. By default, it will return the html content in your HTML/template file, when you define a render function, it(html template) will rendered by your custom render function.// all config
{
// 1. directly input html/template path
login1: '/src/index/index.html',
// 2. a object with template
login2: {
template: '/src/login/login.html', // if there is no data prop, the login.html must only contain HTML content
},
// 3. a object with template and data, maybe with render
login3: {
template: '/src/login1/login1.html',
data: {
users: ['a', 'b', 'c']
},
// each page can have independent render function
// render(template, data){
// return template
// }
}
}
notice:
<$= users.join(" | "); $>
), you must contain template
and data
.pages
options' key
is the real HTML file after buildpages
options' key
and value
/ template
file's name can different.login1.html
when dev
mode, and it will generate a login1.html
when build.pages
set to true
, the template.html
will only generate ONLY ONE html
fileconfig the index page
Ex. when you open http://localhost:3000
, your project's root dir has no index.html
file, then browser will show 404
.
now, if you set this, plugin will intercept /
request, and response with page you set.
Like this: when you set indexPage
to login
,then you access http://localhost:3000
in browser, it will show the /login.html
page.
it equals to access http://localhost:3000/login.html
.
from 0.1.0
, you can use render
function to render html template. i have just test in ejs
, but i think other template system will(maybe) work correctly.
Customize fast-glob
's pattern When set this options, it will replace default fast-glob
pattern, it's default value is ['**/*.html', '!node_modules/**/*.html', '!.**/*.html']
In html file, put replacement
before/after find
template
file for multiple page, plese make sure the page's key is different.Author: windsonR
Source code: https://github.com/windsonR/vite-plugin-virtual-html
License: MIT license
1656651600
vite's MPA unlike @vue/cli
's pages
option have a configuration in dev mode.
vite's html file need to place in project's root to have same behavior in dev and production mode, it makes your project's root dir looks chaotic.
And if you follow vite's MPA, put other file in other directory, unlike index.html
, you need useless middle directory(Ex. from vite's MPA doc http://localhost:3000/nested/nested.html
) to located it.
so, i write this plugin to make vite's MPA more configurable and in dev mode or production has same behavior.
this plugin use vite's configureServer
Hook to intercept html request and response the html content requested from browser.
0.2.9
add a new option injectCode
to add some code before/after tag in html file0.2.8
add a new option extraGlobPattern
to customize fast-glob
's pattern. Default pattern is ['**/*.html', '!node_modules/**/*.html', '!.**/*.html']
, attention: if your config has problems, such as you didn't ignore dist
, when build,it will occur error: new Error('[vite]: Rollup failed to resolve import "${id}" from "${importer}".\n'
0.2.6
pages
now correctly identify multi-level directories0.2.3
pages
options now can set to true to allow all html in project.0.2.1
now works fine with @vitejs/plugin-react
.0.2.0
has reworked, so config have a little changepage
's config renamed to template
page
can have a independent render
functiondata
, its' config will be covered by page
's data
pages
' will be treat as template file@vue/cli
's pages
)pages
.pages
options) under dist's sub-folder to dist folder, and then delete the rest html file.build.rollupOptions.input
from pagesyarn add vite-plugin-virtual-html --dev # npm install vite-plugin-virtual-html -D
Add it to vite.config.js
// vite.config.js
const virtualHtml = require('vite-plugin-virtual-html')
const pages = {
index: '/src/index/index.html',
login: '/src/login/login.html',
}
module.exports = {
plugins: [virtualHtml({
pages,
indexPage: 'login'
})],
}
config your project's all html/template file's path
it will be used for:
build.rollupOptions.input
template
and data
to render it. By default, it will return the html content in your HTML/template file, when you define a render function, it(html template) will rendered by your custom render function.// all config
{
// 1. directly input html/template path
login1: '/src/index/index.html',
// 2. a object with template
login2: {
template: '/src/login/login.html', // if there is no data prop, the login.html must only contain HTML content
},
// 3. a object with template and data, maybe with render
login3: {
template: '/src/login1/login1.html',
data: {
users: ['a', 'b', 'c']
},
// each page can have independent render function
// render(template, data){
// return template
// }
}
}
notice:
<$= users.join(" | "); $>
), you must contain template
and data
.pages
options' key
is the real HTML file after buildpages
options' key
and value
/ template
file's name can different.login1.html
when dev
mode, and it will generate a login1.html
when build.pages
set to true
, the template.html
will only generate ONLY ONE html
fileconfig the index page
Ex. when you open http://localhost:3000
, your project's root dir has no index.html
file, then browser will show 404
.
now, if you set this, plugin will intercept /
request, and response with page you set.
Like this: when you set indexPage
to login
,then you access http://localhost:3000
in browser, it will show the /login.html
page.
it equals to access http://localhost:3000/login.html
.
from 0.1.0
, you can use render
function to render html template. i have just test in ejs
, but i think other template system will(maybe) work correctly.
Customize fast-glob
's pattern When set this options, it will replace default fast-glob
pattern, it's default value is ['**/*.html', '!node_modules/**/*.html', '!.**/*.html']
In html file, put replacement
before/after find
template
file for multiple page, plese make sure the page's key is different.Author: windsonR
Source code: https://github.com/windsonR/vite-plugin-virtual-html
License: MIT license
1600583123
In this article, we are going to list out the most popular websites using Vue JS as their frontend framework.
Vue JS is one of those elite progressive JavaScript frameworks that has huge demand in the web development industry. Many popular websites are developed using Vue in their frontend development because of its imperative features.
This framework was created by Evan You and still it is maintained by his private team members. Vue is of course an open-source framework which is based on MVVM concept (Model-view view-Model) and used extensively in building sublime user-interfaces and also considered a prime choice for developing single-page heavy applications.
Released in February 2014, Vue JS has gained 64,828 stars on Github, making it very popular in recent times.
Evan used Angular JS on many operations while working for Google and integrated many features in Vue to cover the flaws of Angular.
“I figured, what if I could just extract the part that I really liked about Angular and build something really lightweight." - Evan You
#vuejs #vue #vue-with-laravel #vue-top-story #vue-3 #build-vue-frontend #vue-in-laravel #vue.js
1589639315
To create a CLI command, which can create a boilerplate for me(like how vue create does). But for my use case, I want to add some predefined packages, scripts, husky. To enforce some rules (best practices), So everyone in my organization will be on the same page.
And also, to allow the developer to select some inhouse npm packages so that based on the selection, those packages will be installed, and even some code will be injected into the files dynamically.
To achieve the above problem statement, I researched a lot and came to know about vue-CLI-plugin-development, which has excellent documentation but a lack of good examples. So I thought of writing one article which can help you to solve some of the things when you are building a CLI plugin. Let us start.
#vuejs #vue #vue-cli #vue-plugin
1595318322
HTML stands for a hypertext markup language. For the designs to be displayed in web browser HTML is the markup language. Technologies like Cascading style sheets (CSS) and scripting languages such as JavaScript assist HTML. With the help of HTML websites and the web, designs are created. Html has a wide range of academic applications. HTML has a series of elements. HTML helps to display web content. Its elements tell the web how to display the contents.
The document component of HTML is known as an HTML element. HTML element helps in displaying the web pages. An HTML document is a mixture of text nodes and HTML elements.
The simple fundamental components oh HTML is
HTML helps in creating web pages. In web pages, there are texts, pictures, colouring schemes, tables, and a variety of other things. HTML allows all these on a web page.
There are a lot of attributes in HTML. It may get difficult to memorize these attributes. HTML is a tricky concept. Sometimes it gets difficult to find a single mistake that doesn’t let the web page function properly.
Many minor things are to be kept in mind in HTML. To complete an HTML assignment, it is always advisable to seek help from online experts. These experts are well trained and acknowledged with the subject. They provide quality content within the prescribed deadline. With several positive reviews, the online expert help for HTML assignment is highly recommended.
#html assignment help #html assignment writing help #online html assignment writing help #html assignment help service online #what is html #about html
1656932400
out-of-the-box for vue-cli projects without any codebase modifications.
# 1. first step
vue add vite
# 2. second step
# NOTE you cannot directly use `vite` or `npx vite` since it is origin vite not this plugin.
yarn vite // or npm run vite
# 3. add optimizeDeps#include (optional and will speedup devServer start time a lot)
# added in vue.config.js#pluginOptions.vite.optimizeDeps.include
# e.g.: ['vue', 'vue-router', 'vuex']
# all scanned deps(logged in terminal) can be added for speedup.
// vue.config.js
{
// ...
pluginOptions: {
vite: {
/**
* Plugin[]
* @default []
*/
plugins: [], // other vite plugins list, will be merge into this plugin\'s underlying vite.config.ts
/**
* Vite UserConfig.optimizeDeps options
* recommended set `include` for speedup page-loaded time, e.g. include: ['vue', 'vue-router', '@scope/xxx']
* @default {}
*/
optimizeDeps: {},
/**
* type-checker, recommended disabled for large-scale old project.
* @default false
*/
disabledTypeChecker: true,
/**
* lint code by eslint
* @default false
*/
disabledLint: false,
}
},
}
vue-cli-plugin-vite
package.json#scripts#vite
and one file at bin/vite
vue.config.js
(publicPath, alias, outputDir...)Dimension | vue-cli | vite |
---|---|---|
Plugin | 1. based on webpack. 2. have service and generator lifecycles. 3. hooks based on each webpack plugin hooks | 1. based on rollup. 2. no generator lifecycle. 3. universal hooks based on rollup plugin hooks and vite self designed |
Environment Variables | 1. loaded on process.env. 2. prefixed by VUE_APP_ . 3. client-side use process.env.VUE_APP_XXX by webpack definePlugin | 1. not loaded on process.env. 2. prefixed by VITE_ . 3. client-side use import.meta.env.VITE_XXX by vite inner define plugin |
Entry Files | 1. main.{js,ts}. | 1. *.html |
Config File | 1. vue.config.js | 1. vite.config.ts. 2. support use --config to locate |
MPA Support | 1. native support by options.pages . 2. with history rewrite support | 1. native support by rollupOptions.input |
Special Syntax | 1. require(by webpack) 2. require.context(by webpack) 2. use ~some-module/dist/index.css (by css-loader ) 3. module.hot for HMR | 1. import.meta.glob/globEager 2. native support by vite, use module/dist/index.css directly 3. import.meta.hot for HMR |
Local devServer | 1. webpack dev-server 2. express-style middleware and many extension api. | 1. connect 2. connect middleware |
Type Checker | 1. fork-ts-checker-webpack-plugin | 1. No built-in, we can use vite-plugin-checker(based on vetur and vue-tsc) |
Lint | 1. @vue/cli-plugin-eslint | 1. No built-in we can use vite-plugin-eslint, |
Jest | 1. @vue/cli-plugin-jest | 1. will have first-class jest support |
VUE_APP_
prefixprocess.env.${PREFIX}_XXX
for client-sideprocess.env.PUBLIC_URL || vue.config.js#publicPath || baseUrl
css
css.loaderOptions
devServer
process.env.DEV_HOST || devServer.public
Number(process.env.PORT) || devServer.port
devServer.https
process.platform === 'darwin' || devServer.open
devServer.proxy
outputDir
css.extract
process.env.GENERATE_SOURCEMAP === 'true' || productionSourceMap || css.sourceMap
vue.config.js#runtimeCompiler
you can clone/fork this repo, under examples/*
require('xxx')
module.xxx
Author: IndexXuan
Source Code: https://github.com/IndexXuan/vue-cli-plugin-vite
License: MIT license
#vue #vite