Skip to content

Instantly share code, notes, and snippets.

@remmel
Last active June 5, 2024 20:21
Show Gist options
  • Save remmel/ff381e4bd6c4ac8ce8355dcd7cf81ba9 to your computer and use it in GitHub Desktop.
Save remmel/ff381e4bd6c4ac8ce8355dcd7cf81ba9 to your computer and use it in GitHub Desktop.
cxrjs word main iife build
chrome.scripting.registerContentScripts([
{
id: 'XMLOverride',
// js: [leboncoin_mainWorld],
js: ["build-iife/leboncoinfr_content_worldmain.js"],
matches: ["https://www.leboncoin.fr/*"], //also in host_permissions
persistAcrossSessions: true,
runAt: 'document_start',
world: 'MAIN',
},
])
{
web_accessible_resources: [{
"matches": ["https://www.dumb-url-to-force-cxrjs-to-copy.fr/*"],
"resources": [
"build-iife/*.js"
]
}]
}
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
},
"include": ["src"]
}
import path from 'path'
import { glob } from 'glob'
import * as url from 'url'
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
const entryFiles = glob.sync(path.join(__dirname, './src/**/*worldmain.*'))
// Create an entry object where key is the name and value is the path to the file
const entries = entryFiles.reduce((acc, file) => {
const name = path.basename(file, path.extname(file));
acc[name] = file;
return acc;
}, {});
console.log(entryFiles) //, path.resolve(__dirname, 'src'))
export default {
entry: entries,
output: {
path: path.resolve('build-iife'),
iife: true,
},
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.ts$/,
// use: 'ts-loader',
exclude: /node_modules/,
use: [{
loader: 'ts-loader',
options: {
configFile: "tsconfig.webpack.json"
}
}]
},
],
}
};
@remmel
Copy link
Author

remmel commented Jun 5, 2024

It will build as iife files
webpack: /src/**/*worldmain.* -> /build-iife/ (as iife file)
vite/cxrjs: copy build-iife/*.js -> /dist/
Work in dev and build. However, in dev mode webpack changes in ROOT/build-iife are not updated in ROOT/dist/build-iife

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment