@newlogic-digital/core 2.1.2 → 3.0.0-next.2

Sign up to get free protection for your applications and to get access to all the features.
package/index.js CHANGED
@@ -15,6 +15,7 @@ import twigOptions from './src/twig.js'
15
15
  import FastGlob from 'fast-glob'
16
16
  import fse from 'fs-extra'
17
17
  import pc from 'picocolors'
18
+ import browserslistToEsbuild from 'browserslist-to-esbuild'
18
19
 
19
20
  const { name } = getPackageInfo(import.meta.url)
20
21
 
@@ -41,7 +42,7 @@ const posthtmlPrism = {
41
42
 
42
43
  const postcssImportSupports = {
43
44
  name: 'postcss-import-supports',
44
- transform (code, path) {
45
+ transform(code, path) {
45
46
  if (path.endsWith('.css')) {
46
47
  return {
47
48
  code: code.replace('@media supports', '@supports')
@@ -57,33 +58,39 @@ const defaultOptions = {
57
58
  mode: null,
58
59
  cert: 'localhost',
59
60
  format: ['latte'],
61
+ manualChunks: {},
60
62
  emails: {
61
63
  outputDir: resolve(process.cwd(), 'public/email'),
62
64
  appDir: resolve(process.cwd(), 'app/Templates/Emails')
63
65
  },
64
66
  vituum: {
65
67
  pages: {
66
- dir: './src/views'
68
+ dir: './src/pages'
67
69
  }
68
70
  },
69
71
  posthtml: {
70
72
  root: resolve(process.cwd(), 'src')
71
73
  },
72
74
  juice: {
73
- paths: ['src/views/email']
75
+ paths: ['src/pages/email'],
76
+ postcss: {
77
+ globalData: {
78
+ files: ['./src/emails/styles/main/base/config.css']
79
+ }
80
+ }
74
81
  },
75
82
  tailwindcss: {},
76
83
  send: {},
77
84
  latte: {
78
- renderTransformedHtml: (filename) => dirname(filename).endsWith('email'),
85
+ renderTransformedHtml: filename => dirname(filename).endsWith('email'),
79
86
  globals: {
80
87
  srcPath: resolve(process.cwd(), 'src'),
81
88
  templatesPath: resolve(process.cwd(), 'src/templates'),
82
- template: './src/templates/Layout/Main.latte'
89
+ template: './src/templates/layouts/default.latte'
83
90
  },
84
91
  functions: {
85
92
  pages: () => {
86
- return fs.readdirSync(resolve(process.cwd(), 'src/views')).filter(file => fs.statSync(resolve(process.cwd(), 'src/views/' + file)).isFile())
93
+ return fs.readdirSync(resolve(process.cwd(), 'src/pages')).filter(file => fs.statSync(resolve(process.cwd(), 'src/pages/' + file)).isFile())
87
94
  }
88
95
  },
89
96
  filters: {
@@ -126,10 +133,10 @@ const plugin = (options = {}) => {
126
133
  return [{
127
134
  name,
128
135
  enforce: 'pre',
129
- config (userConfig, userEnv) {
130
- const isHttps = userConfig?.server?.https !== false &&
131
- fs.existsSync(join(os.homedir(), `.ssh/${options.cert}.pem`)) &&
132
- fs.existsSync(join(os.homedir(), `.ssh/${options.cert}-key.pem`))
136
+ config(userConfig, userEnv) {
137
+ const isHttps = userConfig?.server?.https !== false
138
+ && fs.existsSync(join(os.homedir(), `.ssh/${options.cert}.pem`))
139
+ && fs.existsSync(join(os.homedir(), `.ssh/${options.cert}-key.pem`))
133
140
 
134
141
  let defaultInput = [
135
142
  './src/styles/*.{css,pcss,scss,sass,less,styl,stylus}',
@@ -142,8 +149,8 @@ const plugin = (options = {}) => {
142
149
 
143
150
  if (options.mode === 'development') {
144
151
  defaultInput = [
145
- './src/views/**/*.{json,latte,twig,liquid,njk,hbs,pug,html}',
146
- '!./src/views/**/*.{latte,twig,liquid,njk,hbs,pug,html}.json',
152
+ './src/pages/**/*.{json,latte,twig,liquid,njk,hbs,pug,html}',
153
+ '!./src/pages/**/*.{latte,twig,liquid,njk,hbs,pug,html}.json',
147
154
  './src/styles/*.{css,pcss,scss,sass,less,styl,stylus}',
148
155
  './src/scripts/*.{js,ts,mjs}'
149
156
  ]
@@ -157,8 +164,8 @@ const plugin = (options = {}) => {
157
164
  userEnv.mode = 'production'
158
165
 
159
166
  defaultInput = [
160
- './src/views/email/**/*.{json,latte,twig,liquid,njk,hbs,pug,html}',
161
- '!./src/views/email/**/*.{latte,twig,liquid,njk,hbs,pug,html}.json'
167
+ './src/pages/email/**/*.{json,latte,twig,liquid,njk,hbs,pug,html}',
168
+ '!./src/pages/email/**/*.{latte,twig,liquid,njk,hbs,pug,html}.json'
162
169
  ]
163
170
  }
164
171
 
@@ -173,7 +180,7 @@ const plugin = (options = {}) => {
173
180
  }, userConfig.optimizeDeps ?? {})
174
181
 
175
182
  userConfig.build = Object.assign({
176
- target: ['edge89', 'firefox89', 'chrome89', 'safari15'],
183
+ target: browserslistToEsbuild(),
177
184
  manifest: 'manifest.json',
178
185
  emptyOutDir: false,
179
186
  modulePreload: false,
@@ -182,7 +189,15 @@ const plugin = (options = {}) => {
182
189
  }, userConfig.build ?? {})
183
190
 
184
191
  userConfig.build.rollupOptions = Object.assign({
185
- input: defaultInput
192
+ input: defaultInput,
193
+ output: {
194
+ manualChunks: {
195
+ swup: ['swup'],
196
+ stimulus: ['@hotwired/stimulus'],
197
+ naja: ['naja'],
198
+ ...options.manualChunks
199
+ }
200
+ }
186
201
  }, userConfig.build.rollupOptions ?? {})
187
202
 
188
203
  userConfig.server = Object.assign({
@@ -192,16 +207,16 @@ const plugin = (options = {}) => {
192
207
  },
193
208
  https: isHttps
194
209
  ? {
195
- key: fs.readFileSync(join(os.homedir(), `.ssh/${options.cert}-key.pem`)),
196
- cert: fs.readFileSync(join(os.homedir(), `.ssh/${options.cert}.pem`))
197
- }
210
+ key: fs.readFileSync(join(os.homedir(), `.ssh/${options.cert}-key.pem`)),
211
+ cert: fs.readFileSync(join(os.homedir(), `.ssh/${options.cert}.pem`))
212
+ }
198
213
  : false
199
214
  }, userConfig.server ?? {})
200
215
  },
201
216
  writeBundle: async () => {
202
217
  if (options.mode === 'emails') {
203
218
  const emails = FastGlob.sync(`${resolve(process.cwd(), options.emails.outputDir)}/**`).filter(entry => !entry.endsWith('test.html'))
204
- const emailsProd = emails.map(path => {
219
+ const emailsProd = emails.map((path) => {
205
220
  return path.replace(resolve(process.cwd(), options.emails.outputDir), resolve(process.cwd(), options.emails.appDir)).replace('.html', '.latte')
206
221
  })
207
222
 
package/package.json CHANGED
@@ -1,38 +1,41 @@
1
1
  {
2
2
  "name": "@newlogic-digital/core",
3
3
  "type": "module",
4
- "version": "2.1.2",
4
+ "version": "3.0.0-next.2",
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",
8
8
  "license": "MIT",
9
9
  "scripts": {
10
10
  "tsc": "tsc",
11
- "eslint": "eslint '**/*.js' --fix"
11
+ "eslint": "eslint '**/*.js' --fix",
12
+ "publish-next": "npm publish --tag next"
12
13
  },
13
14
  "dependencies": {
14
- "@vituum/vite-plugin-posthtml": "^1.1.0",
15
15
  "@vituum/vite-plugin-juice": "^1.2.0",
16
- "@vituum/vite-plugin-latte": "^1.1.0",
17
- "@vituum/vite-plugin-twig": "^1.1.0",
18
- "@vituum/vite-plugin-tailwindcss": "^1.1.0",
16
+ "@vituum/vite-plugin-latte": "^1.2.1",
17
+ "@vituum/vite-plugin-posthtml": "^1.1.0",
19
18
  "@vituum/vite-plugin-send": "^1.1.0",
20
- "vituum": "^1.1.0",
21
- "posthtml": "^0.16.6",
22
- "posthtml-prism": "^2.0.0",
23
- "prismjs": "^1.29.0",
24
- "html-minifier-terser": "^7.2.0",
25
- "lodash": "^4.17.21",
19
+ "@vituum/vite-plugin-tailwindcss": "^1.1.0",
20
+ "@vituum/vite-plugin-twig": "^1.1.0",
26
21
  "fast-glob": "^3.3.2",
27
22
  "fs-extra": "^11.2.0",
28
- "picocolors": "^1.0.0"
23
+ "html-minifier-terser": "^7.2.0",
24
+ "lodash": "^4.17.21",
25
+ "picocolors": "^1.0.1",
26
+ "posthtml": "^0.16.6",
27
+ "posthtml-prism": "^2.0.1",
28
+ "prismjs": "^1.29.0",
29
+ "vituum": "^1.1.1"
29
30
  },
30
31
  "devDependencies": {
31
- "@types/node": "^20.11.24",
32
- "eslint": "^8.57.0",
33
- "eslint-config-standard": "^17.1.0",
34
- "typescript": "^5.3.3",
35
- "vite": "^5.1.5"
32
+ "@types/node": "^22.2.0",
33
+ "browserslist": "^4.23.3",
34
+ "browserslist-to-esbuild": "^2.1.1",
35
+ "eslint": "^9.9.0",
36
+ "neostandard": "^0.11.2",
37
+ "typescript": "^5.5.4",
38
+ "vite": "^5.4.0"
36
39
  },
37
40
  "files": [
38
41
  "latte",
package/src/prism.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import Prism from 'prismjs'
2
- import {render} from 'posthtml-render'
2
+ import { render } from 'posthtml-render'
3
3
  import loadLanguages from 'prismjs/components/index.js'
4
4
  import NormalizeWhitespace from 'prismjs/plugins/normalize-whitespace/prism-normalize-whitespace.js'
5
5
 
@@ -7,22 +7,22 @@ const Normalize = new NormalizeWhitespace({
7
7
  'remove-trailing': true,
8
8
  'remove-indent': true,
9
9
  'left-trim': true,
10
- 'right-trim': true,
11
- });
10
+ 'right-trim': true
11
+ })
12
12
 
13
- const createPrismPlugin = options => {
14
- return tree => {
15
- const highlightCodeTags = node => tree.match.call(node, {tag: 'code'}, highlightNode)
13
+ const createPrismPlugin = (options) => {
14
+ return (tree) => {
15
+ const highlightCodeTags = node => tree.match.call(node, { tag: 'code' }, highlightNode)
16
16
 
17
17
  if (options.inline) {
18
18
  highlightCodeTags(tree)
19
19
  } else {
20
- tree.match({tag: 'pre'}, highlightCodeTags)
20
+ tree.match({ tag: 'pre' }, highlightCodeTags)
21
21
  }
22
22
  }
23
23
  }
24
24
 
25
- const highlightNode = node => {
25
+ const highlightNode = (node) => {
26
26
  const attrs = node.attrs || {}
27
27
  const classList = `${attrs.class || ''}`.trimStart()
28
28
 
@@ -74,13 +74,13 @@ const mapStringOrNode = (stringOrNode, lang = null) => {
74
74
  return stringOrNode
75
75
  }
76
76
 
77
- const getExplicitLanguage = classList => {
77
+ const getExplicitLanguage = (classList) => {
78
78
  const matches = classList.match(/(?:lang|language)-(\w*)/)
79
79
 
80
80
  return matches === null ? null : matches[1]
81
81
  }
82
82
 
83
- const plugin = options => {
83
+ const plugin = (options) => {
84
84
  options = options || {}
85
85
  options.inline = options.inline || false
86
86
 
package/types/index.d.ts CHANGED
@@ -7,8 +7,9 @@ export interface PluginUserConfig {
7
7
  mode?: 'development' | 'production' | 'emails'
8
8
  format?: string[]
9
9
  cert?: string
10
+ manualChunks?: import('rollup').ManualChunksOption
10
11
  emails?: Emails
11
- vituum?: import('vituum/types').UserConfig,
12
+ vituum?: import('vituum').UserConfig,
12
13
  posthtml?: import('@vituum/vite-plugin-posthtml/types').PluginUserConfig
13
14
  juice?: import('@vituum/vite-plugin-juice/types').PluginUserConfig
14
15
  send?: import('@vituum/vite-plugin-send/types').PluginUserConfig