-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: adjust folder structure for compiler (#1099)
* chore: adjust folder structure * chore: add correct path * chore: remove whitespace * chore: cleanup naming * chore: renaming
- Loading branch information
Showing
8 changed files
with
175 additions
and
149 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* (c) Copyright Frontify Ltd., all rights reserved. */ | ||
|
||
import react from '@vitejs/plugin-react'; | ||
import { build } from 'vite'; | ||
import { viteExternalsPlugin } from 'vite-plugin-externals'; | ||
|
||
import { getAppBridgeVersion } from '../appBridgeVersion'; | ||
|
||
import { type CompilerOptions } from './compilerOptions'; | ||
|
||
export const compileBlock = async ({ projectPath, entryFile, outputName }: CompilerOptions) => { | ||
const appBridgeVersion = getAppBridgeVersion(projectPath); | ||
return build({ | ||
plugins: [ | ||
react(), | ||
viteExternalsPlugin({ | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
}), | ||
], | ||
define: { | ||
'process.env.NODE_ENV': JSON.stringify('production'), | ||
}, | ||
root: projectPath, | ||
build: { | ||
lib: { | ||
name: outputName, | ||
entry: entryFile, | ||
formats: ['iife'], | ||
fileName: () => 'index.js', | ||
}, | ||
rollupOptions: { | ||
external: ['react', 'react-dom'], | ||
output: { | ||
globals: { | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
}, | ||
footer: ` | ||
window.${outputName} = ${outputName}; | ||
window.${outputName}.dependencies = window.${outputName}.packages || {}; | ||
window.${outputName}.dependencies['@frontify/app-bridge'] = '${appBridgeVersion}'; | ||
`, | ||
}, | ||
}, | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* (c) Copyright Frontify Ltd., all rights reserved. */ | ||
|
||
import react from '@vitejs/plugin-react'; | ||
import { build } from 'vite'; | ||
import { viteExternalsPlugin } from 'vite-plugin-externals'; | ||
|
||
import { getAppBridgeVersion } from '../appBridgeVersion'; | ||
|
||
import { type CompilerOptions } from './compilerOptions'; | ||
|
||
export const compilePlatformApp = async ({ outputName, entryFile, projectPath = '' }: CompilerOptions) => { | ||
const appBridgeVersion = getAppBridgeVersion(projectPath); | ||
|
||
const settings = await build({ | ||
plugins: [ | ||
react(), | ||
viteExternalsPlugin({ | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
}), | ||
], | ||
root: projectPath, | ||
define: { | ||
'process.env.NODE_ENV': JSON.stringify('production'), | ||
}, | ||
build: { | ||
lib: { | ||
entry: entryFile, | ||
name: outputName, | ||
formats: ['iife'], | ||
fileName: () => 'index.js', | ||
}, | ||
rollupOptions: { | ||
external: ['react', 'react-dom'], | ||
output: { | ||
globals: { | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
}, | ||
entryFileNames: 'settings.js', | ||
footer: ` | ||
window.${outputName} = ${outputName}; | ||
window.${outputName}.dependencies = window.${outputName}.packages || {}; | ||
window.${outputName}.dependencies['@frontify/app-bridge'] = '${appBridgeVersion}'; | ||
`, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
const app = await build({ | ||
plugins: [react()], | ||
root: projectPath, | ||
define: { | ||
'process.env.NODE_ENV': JSON.stringify('production'), | ||
}, | ||
base: '/__DYNAMIC_SEGMENT__/', | ||
build: { | ||
emptyOutDir: false, | ||
}, | ||
}); | ||
return { app, settings }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* (c) Copyright Frontify Ltd., all rights reserved. */ | ||
|
||
import react from '@vitejs/plugin-react'; | ||
import { build } from 'vite'; | ||
import { viteExternalsPlugin } from 'vite-plugin-externals'; | ||
|
||
import { getAppBridgeThemeVersion } from '../appBridgeThemeVersion'; | ||
|
||
import { type CompilerOptions } from './compilerOptions'; | ||
|
||
export const compileTheme = async ({ projectPath, entryFile, outputName }: CompilerOptions) => { | ||
const appBridgeVersion = getAppBridgeThemeVersion(projectPath); | ||
return build({ | ||
plugins: [ | ||
react(), | ||
viteExternalsPlugin({ | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
}), | ||
], | ||
define: { | ||
'process.env.NODE_ENV': JSON.stringify('production'), | ||
}, | ||
root: projectPath, | ||
build: { | ||
lib: { | ||
name: outputName, | ||
entry: entryFile, | ||
formats: ['iife'], | ||
fileName: () => 'index.js', | ||
}, | ||
rollupOptions: { | ||
external: ['react', 'react-dom'], | ||
output: { | ||
globals: { | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
}, | ||
footer: ` | ||
window.${outputName} = ${outputName}; | ||
window.${outputName}.dependencies = window.${outputName}.packages || {}; | ||
window.${outputName}.dependencies['@frontify/app-bridge-theme'] = '${appBridgeVersion}'; | ||
`, | ||
}, | ||
}, | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* (c) Copyright Frontify Ltd., all rights reserved. */ | ||
|
||
export type CompilerOptions = { | ||
projectPath: string; | ||
entryFile: string; | ||
outputName: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters