11/* eslint-disable @typescript-eslint/no-var-requires */
22const path = require ( 'path' ) ;
33const glob = require ( 'glob' ) ;
4- const fs = require ( 'fs' ) ;
54/* eslint-enable @typescript-eslint/no-var-requires */
65
7- const integrationDevPath = path . resolve (
8- __dirname ,
9- 'packages/bundle-odoo-website-editor/odoo-integration.ts' ,
10- ) ;
11-
126const mainConfig = {
137 mode : 'development' ,
148 devtool : 'inline-source-map' ,
@@ -92,9 +86,8 @@ const entries = glob.sync(__dirname + '/examples/**/*.ts').reduce((acc, file) =>
9286 acc [ fileKey ] = file ;
9387 return acc ;
9488} , { } ) ;
95- entries [ 'odoo-integration' ] = integrationDevPath ;
9689
97- module . exports . examples = {
90+ const examplesConfig = {
9891 ...mainConfig ,
9992 entry : entries ,
10093 output : {
@@ -104,41 +97,4 @@ module.exports.examples = {
10497 } ,
10598} ;
10699
107- // -----------------------------------------------------------------------------
108- // Build for Odoo
109- // -----------------------------------------------------------------------------
110- const odooBuildPath = path . resolve ( __dirname , 'build/odoo' ) ;
111- const odooBuildFilename = 'odoo-integration.js' ;
112- module . exports . odoo = {
113- ...mainConfig ,
114- entry : {
115- 'odoo-integration' : integrationDevPath ,
116- } ,
117- output : {
118- path : odooBuildPath ,
119- filename : odooBuildFilename ,
120- library : 'JWEditor' ,
121- } ,
122- plugins : [
123- {
124- apply : compiler => {
125- compiler . hooks . afterEmit . tap ( 'AfterEmitBuildOdooIntegration' , async ( ) => {
126- const filename = path . resolve ( odooBuildPath , odooBuildFilename ) ;
127- fs . readFile ( filename , ( error , content ) => {
128- if ( error ) throw new Error ( error ) ;
129- const newContent = [
130- "odoo.define('web_editor.jabberwock', function(require) {" ,
131- "'use strict';" ,
132- content ,
133- 'return JWEditor' ,
134- '});' ,
135- ] . join ( '\n' ) ;
136- fs . writeFile ( filename , newContent , error => {
137- if ( error ) throw new Error ( error ) ;
138- } ) ;
139- } ) ;
140- } ) ;
141- } ,
142- } ,
143- ] ,
144- } ;
100+ module . exports = examplesConfig ;
0 commit comments