@newlogic-digital/core 3.0.0-next.4 → 3.0.0-next.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +39 -20
  2. package/package.json +17 -15
  3. package/types/index.d.ts +1 -0
package/index.js CHANGED
@@ -3,27 +3,16 @@ import os from 'node:os'
3
3
  import { resolve, join } from 'node:path'
4
4
  import vituum from 'vituum'
5
5
  import latte from '@vituum/vite-plugin-latte'
6
- import twig from '@vituum/vite-plugin-twig'
7
6
  import juice from '@vituum/vite-plugin-juice'
8
7
  import send from '@vituum/vite-plugin-send'
9
- import tailwindcss from '@vituum/vite-plugin-tailwindcss'
10
8
  import { getPackageInfo, merge } from 'vituum/utils/common.js'
11
9
  import twigOptions from './src/twig.js'
12
10
  import browserslistToEsbuild from 'browserslist-to-esbuild'
11
+ import browserslist from 'browserslist'
12
+ import { Features as LightningCssFeatures, browserslistToTargets } from 'lightningcss'
13
13
 
14
14
  const { name } = getPackageInfo(import.meta.url)
15
15
 
16
- const postcssImportSupports = {
17
- name: 'postcss-import-supports',
18
- transform(code, path) {
19
- if (path.endsWith('.css')) {
20
- return {
21
- code: code.replace('@media supports', '@supports')
22
- }
23
- }
24
- }
25
- }
26
-
27
16
  /**
28
17
  * @type {import('@newlogic-digital/core/types').PluginUserConfig}
29
18
  */
@@ -45,6 +34,10 @@ const defaultOptions = {
45
34
  }
46
35
  }
47
36
  },
37
+ css: {
38
+ transformer: 'postcss',
39
+ lightningcss: {}
40
+ },
48
41
  tailwindcss: {},
49
42
  send: {},
50
43
  latte: {
@@ -70,12 +63,15 @@ const defaultOptions = {
70
63
  * @param {import('@newlogic-digital/core/types').PluginUserConfig} options
71
64
  * @returns [import('vite').Plugin]
72
65
  */
73
- const plugin = (options = {}) => {
66
+ const plugin = async (options = {}) => {
74
67
  options = merge(defaultOptions, options)
75
68
 
76
69
  const templatesPlugins = []
70
+ const tailwindcssPlugin = []
77
71
 
78
72
  if (options.format.includes('twig')) {
73
+ const twig = (await import('@vituum/vite-plugin-twig')).default
74
+
79
75
  templatesPlugins.push(twig(options.twig))
80
76
  }
81
77
 
@@ -83,13 +79,24 @@ const plugin = (options = {}) => {
83
79
  templatesPlugins.push(latte(options.latte))
84
80
  }
85
81
 
82
+ if (options.css.transformer === 'postcss') {
83
+ const tailwindcss = (await import('@vituum/vite-plugin-tailwindcss')).default
84
+
85
+ tailwindcssPlugin.push(tailwindcss(options.tailwindcss))
86
+ }
87
+
88
+ if (options.css.transformer === 'lightningcss') {
89
+ const tailwindcss = (await import('@tailwindcss/vite')).default
90
+
91
+ tailwindcssPlugin.push(tailwindcss(options.tailwindcss))
92
+ }
93
+
86
94
  const plugins = [
87
95
  vituum(options.vituum),
88
- tailwindcss(options.tailwindcss),
96
+ ...tailwindcssPlugin,
89
97
  ...templatesPlugins,
90
98
  juice(options.juice),
91
- send(options.send),
92
- postcssImportSupports
99
+ send(options.send)
93
100
  ]
94
101
 
95
102
  return [{
@@ -132,6 +139,18 @@ const plugin = (options = {}) => {
132
139
  entries: []
133
140
  }, userConfig.optimizeDeps ?? {})
134
141
 
142
+ userConfig.css = Object.assign({
143
+ transformer: options.css.transformer
144
+ }, userConfig.css ?? {})
145
+
146
+ userConfig.css.lightningcss = Object.assign({
147
+ targets: browserslistToTargets(browserslist()),
148
+ exclude: LightningCssFeatures.Nesting,
149
+ drafts: {
150
+ customMedia: true
151
+ }
152
+ }, userConfig.css.lightningcss ?? {})
153
+
135
154
  userConfig.build = Object.assign({
136
155
  target: browserslistToEsbuild(),
137
156
  manifest: (options.mode === 'emails') ? false : 'manifest.json',
@@ -160,11 +179,10 @@ const plugin = (options = {}) => {
160
179
  userConfig.build.rollupOptions = Object.assign({
161
180
  input: defaultInput,
162
181
  output: {
163
- manualChunks: {
182
+ manualChunks: options.manualChunks ?? {
164
183
  swup: ['swup'],
165
184
  stimulus: ['@hotwired/stimulus'],
166
- naja: ['naja'],
167
- ...options.manualChunks
185
+ naja: ['naja']
168
186
  }
169
187
  }
170
188
  }, userConfig.build.rollupOptions ?? {})
@@ -172,6 +190,7 @@ const plugin = (options = {}) => {
172
190
 
173
191
  userConfig.server = Object.assign({
174
192
  host: true,
193
+ cors: true,
175
194
  fsServe: {
176
195
  strict: false
177
196
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@newlogic-digital/core",
3
3
  "type": "module",
4
- "version": "3.0.0-next.4",
4
+ "version": "3.0.0-next.6",
5
5
  "main": "index.js",
6
6
  "author": "New Logic Studio s.r.o.",
7
7
  "description": "Set of tools that can be used to create modern web applications",
@@ -12,30 +12,32 @@
12
12
  "publish-next": "npm publish --tag next"
13
13
  },
14
14
  "dependencies": {
15
+ "@tailwindcss/vite": "^4.0.0",
15
16
  "@vituum/vite-plugin-juice": "^1.3.0",
16
- "@vituum/vite-plugin-latte": "^1.2.1",
17
+ "@vituum/vite-plugin-latte": "^1.3.0",
17
18
  "@vituum/vite-plugin-posthtml": "^1.1.0",
18
19
  "@vituum/vite-plugin-send": "^1.1.0",
19
- "@vituum/vite-plugin-tailwindcss": "^1.2.0",
20
- "@vituum/vite-plugin-twig": "^1.1.0",
21
- "fast-glob": "^3.3.2",
22
- "fs-extra": "^11.2.0",
20
+ "browserslist": "^4.24.4",
21
+ "browserslist-to-esbuild": "^2.1.1",
22
+ "fast-glob": "^3.3.3",
23
+ "fs-extra": "^11.3.0",
23
24
  "html-minifier-terser": "^7.2.0",
25
+ "lightningcss": "^1.29.1",
24
26
  "lodash": "^4.17.21",
25
- "picocolors": "^1.1.0",
27
+ "picocolors": "^1.1.1",
26
28
  "posthtml": "^0.16.6",
27
29
  "posthtml-prism": "^2.0.1",
28
30
  "prismjs": "^1.29.0",
29
- "vituum": "^1.1.1",
30
- "browserslist": "^4.24.0",
31
- "browserslist-to-esbuild": "^2.1.1"
31
+ "vituum": "^1.1.1"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/node": "^22.7.5",
35
- "eslint": "^9.12.0",
36
- "neostandard": "^0.11.6",
37
- "typescript": "^5.6.2",
38
- "vite": "^5.4.8"
34
+ "@types/node": "^22.12.0",
35
+ "eslint": "^9.19.0",
36
+ "neostandard": "^0.12.0",
37
+ "typescript": "^5",
38
+ "vite": "^6",
39
+ "@vituum/vite-plugin-tailwindcss": "^1.2.0",
40
+ "@vituum/vite-plugin-twig": "^1.1.0"
39
41
  },
40
42
  "files": [
41
43
  "latte",
package/types/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export interface PluginUserConfig {
10
10
  manualChunks?: import('rollup').ManualChunksOption
11
11
  emails?: Emails
12
12
  vituum?: import('vituum').UserConfig,
13
+ css?: import('vite').CSSOptions
13
14
  posthtml?: import('@vituum/vite-plugin-posthtml/types').PluginUserConfig
14
15
  juice?: import('@vituum/vite-plugin-juice/types').PluginUserConfig
15
16
  send?: import('@vituum/vite-plugin-send/types').PluginUserConfig