Skip to content

Commit 49210f0

Browse files
committed
Чинит сборку
1 parent 8f79e2a commit 49210f0

File tree

2 files changed

+89
-37
lines changed

2 files changed

+89
-37
lines changed

.eleventy.js

Lines changed: 89 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
1+
const path = require('path')
12
const { slugify } = require('transliteration')
23
const htmlnano = require('htmlnano')
34
const markdownIt = require('markdown-it')
45
const { parseHTML } = require('linkedom')
5-
const { isProdEnv } = require('./config/env')
6+
const { isProdEnv } = require('./config/env.js')
67
const { mainSections } = require('./config/constants.js')
7-
const initMarkdownLibrary = require('./src/markdown-it')
8-
const demoLinkTransform = require('./src/transforms/demo-link-transform')
9-
const answersLinkTransform = require('./src/transforms/answers-link-transform')
10-
const imageTransform = require('./src/transforms/image-transform')
11-
const headingsIdTransform = require('./src/transforms/headings-id-transform')
12-
const headingsAnchorTransform = require('./src/transforms/headings-anchor-transform')
13-
const articleCodeBlocksTransform = require('./src/transforms/article-code-blocks-transform')
14-
const articleInlineCodeTransform = require('./src/transforms/article-inline-code-transform')
15-
const colorPickerTransform = require('./src/transforms/color-picker-transform')
16-
const codeClassesTransform = require('./src/transforms/code-classes-transform')
17-
const codeBreakifyTransform = require('./src/transforms/code-breakify-transform')
18-
const tocTransform = require('./src/transforms/toc-transform')
19-
const linkTransform = require('./src/transforms/link-transform')
20-
const iframeAttrTransform = require('./src/transforms/iframe-attr-transform')
21-
const tableTransform = require('./src/transforms/table-transform')
22-
const demoExternalLinkTransform = require('./src/transforms/demo-external-link-transform')
23-
const imagePlaceTransform = require('./src/transforms/image-place-transform')
24-
const detailsTransform = require('./src/transforms/details-transform')
25-
const calloutTransform = require('./src/transforms/callout-transform')
26-
8+
const initMarkdownLibrary = require('./src/markdown-it.js')
9+
const demoLinkTransform = require('./src/transforms/demo-link-transform.js')
10+
const answersLinkTransform = require('./src/transforms/answers-link-transform.js')
11+
const imageTransform = require('./src/transforms/image-transform.js')
12+
const headingsIdTransform = require('./src/transforms/headings-id-transform.js')
13+
const headingsAnchorTransform = require('./src/transforms/headings-anchor-transform.js')
14+
const articleCodeBlocksTransform = require('./src/transforms/article-code-blocks-transform.js')
15+
const articleInlineCodeTransform = require('./src/transforms/article-inline-code-transform.js')
16+
const colorPickerTransform = require('./src/transforms/color-picker-transform.js')
17+
const codeClassesTransform = require('./src/transforms/code-classes-transform.js')
18+
const codeBreakifyTransform = require('./src/transforms/code-breakify-transform.js')
19+
const tocTransform = require('./src/transforms/toc-transform.js')
20+
const linkTransform = require('./src/transforms/link-transform.js')
21+
const iframeAttrTransform = require('./src/transforms/iframe-attr-transform.js')
22+
const tableTransform = require('./src/transforms/table-transform.js')
23+
const demoExternalLinkTransform = require('./src/transforms/demo-external-link-transform.js')
24+
const imagePlaceTransform = require('./src/transforms/image-place-transform.js')
25+
const detailsTransform = require('./src/transforms/details-transform.js')
26+
const calloutTransform = require('./src/transforms/callout-transform.js')
27+
28+
const fetch = require('node-fetch')
2729
const pluginRss = require('@11ty/eleventy-plugin-rss')
30+
const eleventyVitePlugin = require('@11ty/eleventy-plugin-vite')
31+
const postcssImport = require('postcss-import')
32+
const postcssMediaMinmax = require('postcss-media-minmax')
33+
const autoprefixer = require('autoprefixer')
34+
const postcssCsso = require('postcss-csso')
2835

2936
function getAllDocs(collectionAPI) {
3037
const dokas = collectionAPI.getFilteredByTag('doka')
@@ -59,14 +66,10 @@ function getAllDocsByCategory(collectionAPI, category) {
5966
module.exports = function (config) {
6067
config.setDataDeepMerge(true)
6168

62-
config.setServerOptions({
63-
liveReload: true,
64-
domDiff: true,
65-
port: 8080,
66-
watch: ['src/styles/**/*.*', 'src/scripts/**/*.*'],
67-
showAllHosts: false,
68-
encoding: 'utf-8',
69-
showVersion: false,
69+
config.addPlugin(pluginRss, {
70+
posthtmlRenderOptions: {
71+
closingSingleTag: 'default',
72+
},
7073
})
7174

7275
// Add all Tags
@@ -409,6 +412,14 @@ module.exports = function (config) {
409412
}
410413

411414
if (isProdEnv) {
415+
config.setBrowserSyncConfig({
416+
server: {
417+
baseDir: ['./src', './dist', './node_modules'],
418+
},
419+
files: ['src/styles/**/*.*', 'src/scripts/**/*.*'],
420+
ghostMode: false,
421+
})
422+
412423
config.addTransform('html-min', (content, outputPath) => {
413424
if (outputPath) {
414425
let isHtml = outputPath.endsWith('.html')
@@ -440,14 +451,57 @@ module.exports = function (config) {
440451

441452
return content
442453
})
454+
} else {
455+
config.addPlugin(eleventyVitePlugin, {
456+
showAllHosts: true,
457+
458+
serverOptions: {
459+
liveReload: true,
460+
domDiff: true,
461+
port: 8080,
462+
showAllHosts: false,
463+
encoding: 'utf-8',
464+
showVersion: false,
465+
},
466+
467+
viteOptions: {
468+
clearScreen: false,
469+
appType: 'mpa',
470+
471+
server: {
472+
mode: 'development',
473+
middlewareMode: true,
474+
},
475+
476+
cacheDir: '.vite',
477+
478+
css: {
479+
postcss: {
480+
plugins: [
481+
postcssImport,
482+
postcssMediaMinmax,
483+
autoprefixer,
484+
postcssCsso({
485+
restructure: false,
486+
}),
487+
],
488+
},
489+
},
490+
491+
resolve: {
492+
alias: {
493+
'/sw.js': path.resolve('.', 'src/sw.js'),
494+
'/scripts': path.resolve('.', 'src/scripts'),
495+
scripts: path.resolve('.', 'src/scripts'),
496+
'/styles': path.resolve('.', 'src/styles'),
497+
styles: path.resolve('.', 'src/styles'),
498+
'/node_modules': path.resolve('.', 'node_modules'),
499+
},
500+
},
501+
},
502+
})
443503
}
444504

445-
config.addPlugin(pluginRss, {
446-
posthtmlRenderOptions: {
447-
closingSingleTag: 'default',
448-
},
449-
})
450-
451505
config.addPassthroughCopy('src/favicon.ico')
452506
config.addPassthroughCopy('src/manifest.json')
453507
config.addPassthroughCopy('src/robots.txt')

.eleventyignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)