Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(common): resolve source instead of bundle on development #264

Merged
merged 8 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"check:types": "yarn workspaces foreach run check:types",
"lint": "eslint .",
"dev:container": "yarn workspace container dev",
"dev:react": "yarn workspace field-plugin-react-template dev",
"dev:js": "yarn workspace field-plugin-js-template dev",
"dev:vue2": "yarn workspace field-plugin-vue2-template dev",
"dev:vue3": "yarn workspace field-plugin-vue3-template dev",
"dev:react": "yarn workspace field-plugin-react-template dev --config ../../dev/react-vite.config.ts",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this yarn workspace command is run, process.cwd() will be packages/cli/templates/react, not the root directory. So, the config path looks like that.

"dev:js": "yarn workspace field-plugin-js-template dev --config ../../dev/js-vite.config.ts",
"dev:vue2": "yarn workspace field-plugin-vue2-template dev --config ../../dev/vue2-vite.config.ts",
"dev:vue3": "yarn workspace field-plugin-vue3-template dev --config ../../dev/vue3-vite.config.ts",
"dev:demo": "yarn workspace demo dev",
"dev:lib": "yarn workspace @storyblok/field-plugin dev",
"bump-version": "./scripts/bump-version.mjs"
Expand Down
15 changes: 15 additions & 0 deletions packages/cli/dev/js-vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from 'vite'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said in the description of this PR, we're having this separate vite config files here, but they're actually extending the real configs, adding only this alias.

import base from '../templates/js/vite.config'
import path from 'path'

export default defineConfig({
...base,
resolve: {
alias: [
{
find: /^@storyblok\/field-plugin$/,
replacement: path.resolve(__dirname, '../../field-plugin/src/index.ts'),
},
],
},
})
15 changes: 15 additions & 0 deletions packages/cli/dev/react-vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from 'vite'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I welcome any suggestion on this folder or filenames.

import base from '../templates/react/vite.config'
import path from 'path'

export default defineConfig({
...base,
resolve: {
alias: [
{
find: /^@storyblok\/field-plugin$/,
replacement: path.resolve(__dirname, '../../field-plugin/src/index.ts'),
},
],
},
})
15 changes: 15 additions & 0 deletions packages/cli/dev/vue2-vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from 'vite'
import base from '../templates/vue2/vite.config'
import path from 'path'

export default defineConfig({
...base,
resolve: {
alias: [
{
find: /^@storyblok\/field-plugin$/,
replacement: path.resolve(__dirname, '../../field-plugin/src/index.ts'),
},
],
},
})
15 changes: 15 additions & 0 deletions packages/cli/dev/vue3-vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from 'vite'
import base from '../templates/vue3/vite.config'
import path from 'path'

export default defineConfig({
...base,
resolve: {
alias: [
{
find: /^@storyblok\/field-plugin$/,
replacement: path.resolve(__dirname, '../../field-plugin/src/index.ts'),
},
],
},
})
15 changes: 15 additions & 0 deletions packages/container/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'

export default defineConfig({
plugins: [react()],
Expand All @@ -12,6 +13,20 @@ export default defineConfig({
},
},
},
resolve: {
alias:
process.env.NODE_ENV === 'production'
? []
: [
{
find: /^@storyblok\/field-plugin$/,
replacement: path.resolve(
__dirname,
'../field-plugin/src/index.ts',
),
},
],
},
server: {
port: 7070,
host: true,
Expand Down
15 changes: 15 additions & 0 deletions packages/demo/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'

export default defineConfig({
plugins: [react()],
Expand All @@ -12,6 +13,20 @@ export default defineConfig({
},
},
},
resolve: {
alias:
process.env.NODE_ENV === 'production'
? []
: [
{
find: /^@storyblok\/field-plugin$/,
replacement: path.resolve(
__dirname,
'../field-plugin/src/index.ts',
),
},
],
},
server: {
port: 8080,
host: true,
Expand Down
13 changes: 12 additions & 1 deletion packages/field-plugin/helpers/react/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PluginOption, defineConfig } from 'vite'
import { defineConfig, PluginOption } from 'vite'
import react from '@vitejs/plugin-react'
import dts from 'vite-plugin-dts'
import { resolve } from 'path'
Expand All @@ -24,4 +24,15 @@ export default defineConfig({
},
},
},
resolve: {
alias:
process.env.NODE_ENV === 'production'
? []
: [
{
find: /^@storyblok\/field-plugin$/,
replacement: resolve(__dirname, '../field-plugin/src/index.ts'),
},
],
},
})
13 changes: 12 additions & 1 deletion packages/field-plugin/helpers/vite/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PluginOption, defineConfig } from 'vite'
import { defineConfig, PluginOption } from 'vite'
import dts from 'vite-plugin-dts'
import { resolve } from 'path'

Expand All @@ -17,4 +17,15 @@ export default defineConfig({
external: ['querystring'],
},
},
resolve: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eunjae-lee, I may be not seeing something here, but does it make sense to have this alias also for the vite helper?

I mean, it seems that the @storyblok/field-plugin package is not used in this helper...Am I right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, nice catch! Thanks

alias:
process.env.node_env === 'production'
? []
: [
{
find: /^@storyblok\/field-plugin$/,
replacement: resolve(__dirname, '../field-plugin/src/index.ts'),
},
],
},
})
11 changes: 11 additions & 0 deletions packages/field-plugin/helpers/vue2/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,15 @@ export default defineConfig({
},
},
},
resolve: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is totally fine for now, but the helpers will also need some kind of automated mechanism in the future, so that the developer does not need to take care of it.

alias:
process.env.node_env === 'production'
? []
: [
{
find: /^@storyblok\/field-plugin$/,
replacement: resolve(__dirname, '../field-plugin/src/index.ts'),
},
],
},
})
13 changes: 12 additions & 1 deletion packages/field-plugin/helpers/vue3/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import vue from '@vitejs/plugin-vue'
import { PluginOption, defineConfig } from 'vite'
import { defineConfig, PluginOption } from 'vite'
import dts from 'vite-plugin-dts'
import { resolve } from 'path'

Expand All @@ -24,4 +24,15 @@ export default defineConfig({
},
},
},
resolve: {
alias:
process.env.node_env === 'production'
? []
: [
{
find: /^@storyblok\/field-plugin$/,
replacement: resolve(__dirname, '../field-plugin/src/index.ts'),
},
],
},
})