Closed realrecordzLab closed 1 year ago
How I can force the build process to include popup.html or newtab.html page or any other html page my extension need? When I comment the
default_action
the popup page will be not included into the dist folder after build.
so two questions:
replied of questions below:
create-chrome-ext
will fix this in version 0.7.0
How I can force the build process to include popup.html or newtab.html page or any other html page my extension need? When I comment the
default_action
the popup page will be not included into the dist folder after build.so two questions:
- popup.html do not work
- newtab.html(and other html page) not included into dist
replied of questions below:
- which boilerplate you selected?
- pages( newtab \ devtool) are not supported yet.
create-chrome-ext
will fix this in version0.7.0
I've used the vue javascript template
I've readed the docs of the crx.js plugin and I've found a little trick to include extra web pages inside the packed extension. As described into the docs, to add a page to the dev mode and to the build the following code need to be added to the vite.config.js
file
export default defineConfig({
build: {
rollupOptions: {
input: {
popup: 'pages/popup.html',
},
},
},
})
It will be great if the newtab.vue
file can be included into the build using this way, at the moment I'm not sure how to proceed to achive this, but I've successfully included the popup.html
page without declaring it inside the manifest
file
For the time being, there's a way I use to auto generate pages.
import globSync from 'glob';
const pages = await globSync('pages/*.html')
const arrayKeyValuePairs = pages.map(file => [file.split('\\').slice(-1).toString().split('.html').join(''), file])
export const config = Object.fromEntries(arrayKeyValuePairs)
//@ts-ignore
import {config} from './src/read_pages_folder'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
return {
build: {
emptyOutDir: true,
outDir: 'build',
rollupOptions: {
input: config,
output: {
chunkFileNames: 'assets/chunk-[hash].js',
},
},
},
plugins: [crx({ manifest }), react()],
}
})
Afterwards just make a directory pages (Outside of src), and add html files to it, test build :D
How I can force the build process to include popup.html or newtab.html page or any other html page my extension need? When I comment the
default_action
the popup page will be not included into the dist folder after build.