mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 00:39:45 +02:00
Prettify all JavaScript files (#964)
* Prettify all JavaScript files * Make trailingComma all * Delete v2/.prettierignore * Remove v2 Prettier commands in package.json
This commit is contained in:
parent
a1de6dab04
commit
9d4a5d5359
101 changed files with 441 additions and 473 deletions
|
@ -42,7 +42,7 @@ module.exports = async function build(siteDir, cliOptions = {}) {
|
|||
|
||||
// apply user webpack config
|
||||
const {
|
||||
siteConfig: {configureWebpack}
|
||||
siteConfig: {configureWebpack},
|
||||
} = props;
|
||||
clientConfig = applyConfigureWebpack(configureWebpack, clientConfig, false);
|
||||
serverConfig = applyConfigureWebpack(configureWebpack, serverConfig, true);
|
||||
|
@ -58,20 +58,20 @@ module.exports = async function build(siteDir, cliOptions = {}) {
|
|||
const {outDir} = props;
|
||||
const staticDir = path.resolve(siteDir, 'static');
|
||||
const staticFiles = await globby(['**'], {
|
||||
cwd: staticDir
|
||||
cwd: staticDir,
|
||||
});
|
||||
await Promise.all(
|
||||
staticFiles.map(async source => {
|
||||
const fromPath = path.resolve(staticDir, source);
|
||||
const toPath = path.resolve(outDir, source);
|
||||
return fs.copy(fromPath, toPath);
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
const relativeDir = path.relative(process.cwd(), outDir);
|
||||
console.log(
|
||||
`\n${chalk.green('Success!')} Generated static files in ${chalk.cyan(
|
||||
relativeDir
|
||||
)}.\n`
|
||||
relativeDir,
|
||||
)}.\n`,
|
||||
);
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@ module.exports = async function eject(siteDir) {
|
|||
const relativeDir = path.relative(process.cwd(), customTheme);
|
||||
console.log(
|
||||
`\n${chalk.green('Success!')} Copied default theme files to ${chalk.cyan(
|
||||
relativeDir
|
||||
)}.\n`
|
||||
relativeDir,
|
||||
)}.\n`,
|
||||
);
|
||||
};
|
||||
|
|
|
@ -44,8 +44,8 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
|||
[`../${docsRelativeDir}/**/*.md`, 'blog/**/*.md', 'siteConfig.js'],
|
||||
{
|
||||
cwd: siteDir,
|
||||
ignoreInitial: true
|
||||
}
|
||||
ignoreInitial: true,
|
||||
},
|
||||
);
|
||||
fsWatcher.on('add', reload);
|
||||
fsWatcher.on('change', reload);
|
||||
|
@ -69,14 +69,14 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
|||
hash: true,
|
||||
template: path.resolve(__dirname, '../core/devTemplate.ejs'),
|
||||
filename: 'index.html',
|
||||
title: siteConfig.title
|
||||
}
|
||||
title: siteConfig.title,
|
||||
},
|
||||
]);
|
||||
config = config.toConfig();
|
||||
|
||||
// apply user webpack config
|
||||
const {
|
||||
siteConfig: {configureWebpack}
|
||||
siteConfig: {configureWebpack},
|
||||
} = props;
|
||||
config = applyConfigureWebpack(configureWebpack, config, false);
|
||||
|
||||
|
@ -90,11 +90,11 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
|||
compiler,
|
||||
open: true,
|
||||
devMiddleware: {
|
||||
logLevel: 'silent'
|
||||
logLevel: 'silent',
|
||||
},
|
||||
hotClient: {
|
||||
port: hotPort,
|
||||
logLevel: 'error'
|
||||
logLevel: 'error',
|
||||
},
|
||||
logLevel: 'error',
|
||||
port,
|
||||
|
@ -113,12 +113,12 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
|||
app.use(
|
||||
convert(
|
||||
history({
|
||||
rewrites: [{from: /\.html$/, to: '/'}]
|
||||
})
|
||||
)
|
||||
rewrites: [{from: /\.html$/, to: '/'}],
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
);
|
||||
}, 1000);
|
||||
};
|
||||
|
|
|
@ -11,5 +11,5 @@ export default () =>
|
|||
docsMetadatas,
|
||||
docsSidebars,
|
||||
pagesMetadatas,
|
||||
siteConfig
|
||||
siteConfig,
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>,
|
||||
document.getElementById('app')
|
||||
document.getElementById('app'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ export default function prerender(routeConfig, providedLocation) {
|
|||
return component.preload();
|
||||
}
|
||||
return undefined;
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ export default function render(locals) {
|
|||
const appHtml = ReactDOMServer.renderToString(
|
||||
<StaticRouter location={locals.path} context={context}>
|
||||
<App />
|
||||
</StaticRouter>
|
||||
</StaticRouter>,
|
||||
);
|
||||
|
||||
const helmet = Helmet.renderStatic();
|
||||
|
@ -24,7 +24,7 @@ export default function render(locals) {
|
|||
const metaStrings = [
|
||||
helmet.title.toString(),
|
||||
helmet.meta.toString(),
|
||||
helmet.link.toString()
|
||||
helmet.link.toString(),
|
||||
];
|
||||
const metaHtml = metaStrings.filter(Boolean).join('\n ');
|
||||
|
||||
|
@ -42,14 +42,14 @@ export default function render(locals) {
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
${cssFiles.map(
|
||||
cssFile =>
|
||||
`<link rel="stylesheet" type="text/css" href="${baseUrl}${cssFile}" />`
|
||||
`<link rel="stylesheet" type="text/css" href="${baseUrl}${cssFile}" />`,
|
||||
)}
|
||||
</head>
|
||||
<body${bodyAttributes ? ` ${bodyAttributes}` : ''}>
|
||||
<div id="app">${appHtml}</div>
|
||||
${jsFiles.map(
|
||||
jsFile =>
|
||||
`<script type="text/javascript" src="${baseUrl}${jsFile}"></script>`
|
||||
`<script type="text/javascript" src="${baseUrl}${jsFile}"></script>`,
|
||||
)}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -7,5 +7,5 @@ module.exports = {
|
|||
build,
|
||||
eject,
|
||||
init,
|
||||
start
|
||||
start,
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@ module.exports = function loadConfig(siteDir, deleteCache = true) {
|
|||
'tagline',
|
||||
'organizationName',
|
||||
'projectName',
|
||||
'baseUrl'
|
||||
'baseUrl',
|
||||
];
|
||||
const optionalFields = [
|
||||
'customDocsPath',
|
||||
|
@ -26,19 +26,19 @@ module.exports = function loadConfig(siteDir, deleteCache = true) {
|
|||
'configureWebpack',
|
||||
'chainWebpack',
|
||||
'docsUrl',
|
||||
'customFields'
|
||||
'customFields',
|
||||
];
|
||||
const missingFields = requiredFields.filter(field => !config[field]);
|
||||
if (missingFields && missingFields.length > 0) {
|
||||
throw new Error(
|
||||
`${missingFields.join(', ')} fields are missing in siteConfig.js`
|
||||
`${missingFields.join(', ')} fields are missing in siteConfig.js`,
|
||||
);
|
||||
}
|
||||
|
||||
/* Fill default value */
|
||||
const defaultConfig = {
|
||||
customDocsPath: 'docs',
|
||||
docsUrl: 'docs'
|
||||
docsUrl: 'docs',
|
||||
};
|
||||
Object.keys(defaultConfig).forEach(field => {
|
||||
if (!config[field]) {
|
||||
|
@ -55,11 +55,11 @@ module.exports = function loadConfig(siteDir, deleteCache = true) {
|
|||
/* We don't allow useless/ not meaningful field */
|
||||
const allowedFields = [...requiredFields, ...optionalFields, ...customFields];
|
||||
const uselessFields = Object.keys(config).filter(
|
||||
field => !allowedFields.includes(field)
|
||||
field => !allowedFields.includes(field),
|
||||
);
|
||||
if (uselessFields && uselessFields.length > 0) {
|
||||
throw new Error(
|
||||
`${uselessFields.join(', ')} fields are useless in siteConfig.js`
|
||||
`${uselessFields.join(', ')} fields are useless in siteConfig.js`,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ async function loadDocs({siteDir, docsDir, env, siteConfig}) {
|
|||
|
||||
/* metadata for default docs files */
|
||||
const docsFiles = await globby(['**/*.md'], {
|
||||
cwd: docsDir
|
||||
cwd: docsDir,
|
||||
});
|
||||
await Promise.all(
|
||||
docsFiles.map(async source => {
|
||||
|
@ -47,17 +47,17 @@ async function loadDocs({siteDir, docsDir, env, siteConfig}) {
|
|||
docsDir,
|
||||
env,
|
||||
order,
|
||||
siteConfig
|
||||
siteConfig,
|
||||
);
|
||||
docsMetadatas[metadata.id] = metadata;
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
/* metadata for non-default-language docs */
|
||||
if (translationEnabled) {
|
||||
const translatedDir = path.join(siteDir, 'translated_docs');
|
||||
const translatedFiles = await globby(['**/*.md'], {
|
||||
cwd: translatedDir
|
||||
cwd: translatedDir,
|
||||
});
|
||||
await Promise.all(
|
||||
translatedFiles.map(async source => {
|
||||
|
@ -79,10 +79,10 @@ async function loadDocs({siteDir, docsDir, env, siteConfig}) {
|
|||
translatedDir,
|
||||
env,
|
||||
order,
|
||||
siteConfig
|
||||
siteConfig,
|
||||
);
|
||||
docsMetadatas[metadata.id] = metadata;
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ async function loadDocs({siteDir, docsDir, env, siteConfig}) {
|
|||
if (versioningEnabled) {
|
||||
const versionedDir = path.join(siteDir, 'versioned_docs');
|
||||
const versionedFiles = await globby(['**/*.md'], {
|
||||
cwd: versionedDir
|
||||
cwd: versionedDir,
|
||||
});
|
||||
await Promise.all(
|
||||
versionedFiles.map(async source => {
|
||||
|
@ -99,10 +99,10 @@ async function loadDocs({siteDir, docsDir, env, siteConfig}) {
|
|||
versionedDir,
|
||||
env,
|
||||
order,
|
||||
siteConfig
|
||||
siteConfig,
|
||||
);
|
||||
docsMetadatas[metadata.id] = metadata;
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ async function loadDocs({siteDir, docsDir, env, siteConfig}) {
|
|||
|
||||
return {
|
||||
docsSidebars,
|
||||
docsMetadatas
|
||||
docsMetadatas,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ module.exports = async function processMetadata(
|
|||
refDir,
|
||||
env,
|
||||
order,
|
||||
siteConfig
|
||||
siteConfig,
|
||||
) {
|
||||
const filepath = path.resolve(refDir, source);
|
||||
const fileString = await fs.readFile(filepath, 'utf-8');
|
||||
|
@ -131,7 +131,7 @@ module.exports = async function processMetadata(
|
|||
.replace(/:docsUrl/, docsUrl)
|
||||
.replace(/:langPart/, langPart)
|
||||
.replace(/:versionPart/, versionPart)
|
||||
.replace(/:id/, metadata.id)
|
||||
.replace(/:id/, metadata.id),
|
||||
);
|
||||
} else {
|
||||
metadata.permalink = `${baseUrl}${docsUrl}/${langPart}${versionPart}${
|
||||
|
|
|
@ -28,7 +28,7 @@ module.exports = function createOrder(allSidebars = {}) {
|
|||
previous,
|
||||
next,
|
||||
sidebar,
|
||||
category: categoryOrder[i]
|
||||
category: categoryOrder[i],
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ module.exports = function loadSidebars({siteDir, env}) {
|
|||
const versionedSidebarsJSONFile = path.join(
|
||||
siteDir,
|
||||
'versioned_sidebars',
|
||||
`version-${version}-sidebars.json`
|
||||
`version-${version}-sidebars.json`,
|
||||
);
|
||||
if (fs.existsSync(versionedSidebarsJSONFile)) {
|
||||
const sidebar = require(versionedSidebarsJSONFile); // eslint-disable-line
|
||||
|
|
|
@ -7,7 +7,7 @@ module.exports = function loadEnv({siteDir, siteConfig}) {
|
|||
const translation = {
|
||||
enabled: false,
|
||||
enabledLanguages: [],
|
||||
defaultLanguage: {}
|
||||
defaultLanguage: {},
|
||||
};
|
||||
|
||||
const languagesFile = path.join(siteDir, 'languages.js');
|
||||
|
@ -24,11 +24,11 @@ module.exports = function loadEnv({siteDir, siteConfig}) {
|
|||
/* Default Language */
|
||||
const {defaultLanguage: defaultLanguageTag} = siteConfig;
|
||||
const defaultLanguage = enabledLanguages.find(
|
||||
lang => lang.tag === defaultLanguageTag
|
||||
lang => lang.tag === defaultLanguageTag,
|
||||
);
|
||||
if (!defaultLanguage) {
|
||||
throw new Error(
|
||||
`Please set a default language in 'siteConfig.js' which is enabled in 'languages.js'`
|
||||
`Please set a default language in 'siteConfig.js' which is enabled in 'languages.js'`,
|
||||
);
|
||||
}
|
||||
translation.defaultLanguage = defaultLanguage;
|
||||
|
@ -41,7 +41,7 @@ module.exports = function loadEnv({siteDir, siteConfig}) {
|
|||
enabled: false,
|
||||
latestVersion: null,
|
||||
defaultVersion: null,
|
||||
versions: []
|
||||
versions: [],
|
||||
};
|
||||
|
||||
const versionsJSONFile = path.join(siteDir, 'versions.json');
|
||||
|
@ -55,6 +55,6 @@ module.exports = function loadEnv({siteDir, siteConfig}) {
|
|||
|
||||
return {
|
||||
translation,
|
||||
versioning
|
||||
versioning,
|
||||
};
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ module.exports = async function load(siteDir) {
|
|||
const siteConfig = loadConfig(siteDir);
|
||||
await generate(
|
||||
'siteConfig.js',
|
||||
`export default ${JSON.stringify(siteConfig, null, 2)};`
|
||||
`export default ${JSON.stringify(siteConfig, null, 2)};`,
|
||||
);
|
||||
|
||||
// @tested - env
|
||||
|
@ -24,15 +24,15 @@ module.exports = async function load(siteDir) {
|
|||
siteDir,
|
||||
docsDir,
|
||||
env,
|
||||
siteConfig
|
||||
siteConfig,
|
||||
});
|
||||
await generate(
|
||||
'docsMetadatas.js',
|
||||
`export default ${JSON.stringify(docsMetadatas, null, 2)};`
|
||||
`export default ${JSON.stringify(docsMetadatas, null, 2)};`,
|
||||
);
|
||||
await generate(
|
||||
'docsSidebars.js',
|
||||
`export default ${JSON.stringify(docsSidebars, null, 2)};`
|
||||
`export default ${JSON.stringify(docsSidebars, null, 2)};`,
|
||||
);
|
||||
|
||||
/* Create source to metadata mapping */
|
||||
|
@ -42,9 +42,9 @@ module.exports = async function load(siteDir) {
|
|||
sourceToMetadata[source] = {
|
||||
version,
|
||||
permalink,
|
||||
language
|
||||
language,
|
||||
};
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// pages
|
||||
|
@ -52,7 +52,7 @@ module.exports = async function load(siteDir) {
|
|||
const pagesMetadatas = await loadPages(pagesDir);
|
||||
await generate(
|
||||
'pagesMetadatas.js',
|
||||
`export default ${JSON.stringify(pagesMetadatas, null, 2)};`
|
||||
`export default ${JSON.stringify(pagesMetadatas, null, 2)};`,
|
||||
);
|
||||
|
||||
// resolve outDir
|
||||
|
@ -79,7 +79,7 @@ module.exports = async function load(siteDir) {
|
|||
baseUrl,
|
||||
sourceToMetadata,
|
||||
versionedDir,
|
||||
translatedDir
|
||||
translatedDir,
|
||||
};
|
||||
|
||||
// Generate React Router Config
|
||||
|
|
|
@ -3,14 +3,14 @@ const {encodePath, fileToPath} = require('./utils');
|
|||
|
||||
async function loadPages(pagesDir) {
|
||||
const pagesFiles = await globby(['**/*.js'], {
|
||||
cwd: pagesDir
|
||||
cwd: pagesDir,
|
||||
});
|
||||
|
||||
const pagesMetadatas = await Promise.all(
|
||||
pagesFiles.map(async source => ({
|
||||
path: encodePath(fileToPath(source)),
|
||||
source
|
||||
}))
|
||||
source,
|
||||
})),
|
||||
);
|
||||
return pagesMetadatas;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ module.exports = function loadConfig(siteDir) {
|
|||
themeComponents.forEach(component => {
|
||||
if (!require.resolve(path.join(themePath, component))) {
|
||||
throw new Error(
|
||||
`Failed to load ${themePath}/${component}. It does not exist.`
|
||||
`Failed to load ${themePath}/${component}. It does not exist.`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -55,7 +55,7 @@ function getSubFolder(file, refDir) {
|
|||
const separator = escapeStringRegexp(path.sep);
|
||||
const baseDir = escapeStringRegexp(path.basename(refDir));
|
||||
const regexSubFolder = new RegExp(
|
||||
`${baseDir}${separator}(.*?)${separator}.*`
|
||||
`${baseDir}${separator}(.*?)${separator}.*`,
|
||||
);
|
||||
const match = regexSubFolder.exec(file);
|
||||
return match && match[1];
|
||||
|
@ -77,5 +77,5 @@ module.exports = {
|
|||
fileToComponentName,
|
||||
getSubFolder,
|
||||
idx,
|
||||
parse
|
||||
parse,
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ export default class Docs extends React.Component {
|
|||
const linkMetadata = docsMetadatas[linkID];
|
||||
if (!linkMetadata) {
|
||||
throw new Error(
|
||||
`Improper sidebars.json file, document with id '${linkID}' not found.`
|
||||
`Improper sidebars.json file, document with id '${linkID}' not found.`,
|
||||
);
|
||||
}
|
||||
const linkClassName =
|
||||
|
@ -50,7 +50,7 @@ export default class Docs extends React.Component {
|
|||
siteConfig,
|
||||
docsMetadatas,
|
||||
docsSidebars,
|
||||
metadata
|
||||
metadata,
|
||||
} = this.props;
|
||||
return (
|
||||
<Layout {...this.props}>
|
||||
|
|
|
@ -7,7 +7,7 @@ export default class Layout extends React.Component {
|
|||
render() {
|
||||
const {children, pagesMetadatas, docsMetadatas = {}, location} = this.props;
|
||||
const docsLinks = Object.values(docsMetadatas).map(data => ({
|
||||
path: `${data.permalink}`
|
||||
path: `${data.permalink}`,
|
||||
}));
|
||||
const routeLinks = [...pagesMetadatas, ...docsLinks].map(
|
||||
data =>
|
||||
|
@ -15,7 +15,7 @@ export default class Layout extends React.Component {
|
|||
<li key={data.path}>
|
||||
<Link to={data.path}>{data.path}</Link>
|
||||
</li>
|
||||
)
|
||||
),
|
||||
);
|
||||
return (
|
||||
<div>
|
||||
|
|
|
@ -14,8 +14,8 @@ export default (str, rawLang) => {
|
|||
} catch (e) {
|
||||
console.error(
|
||||
chalk.yellow(
|
||||
`Highlight.js syntax highlighting for language "${lang}" is not supported.`
|
||||
)
|
||||
`Highlight.js syntax highlighting for language "${lang}" is not supported.`,
|
||||
),
|
||||
);
|
||||
}
|
||||
return hljs.highlightAuto(str).value;
|
||||
|
|
|
@ -12,7 +12,7 @@ class MarkdownBlock extends React.Component {
|
|||
return (
|
||||
<span
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: this.renderMarkdown(this.props.source)
|
||||
__html: this.renderMarkdown(this.props.source),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
@ -31,14 +31,14 @@ class MarkdownBlock extends React.Component {
|
|||
|
||||
renderMarkdown(source) {
|
||||
const alias = {
|
||||
js: 'jsx'
|
||||
js: 'jsx',
|
||||
};
|
||||
const {siteConfig} = this.props;
|
||||
const md = new Markdown({
|
||||
langPrefix: 'hljs css language-',
|
||||
highlight: highlight,
|
||||
html: true,
|
||||
linkify: true
|
||||
linkify: true,
|
||||
});
|
||||
|
||||
// Register anchors plugin
|
||||
|
@ -64,9 +64,9 @@ class MarkdownBlock extends React.Component {
|
|||
{},
|
||||
{
|
||||
version: '9.12.0',
|
||||
theme: 'default'
|
||||
theme: 'default',
|
||||
},
|
||||
siteConfig.highlight
|
||||
siteConfig.highlight,
|
||||
);
|
||||
|
||||
// Use user-provided themeUrl if it exists, else construct one from version and theme.
|
||||
|
@ -88,7 +88,7 @@ class MarkdownBlock extends React.Component {
|
|||
}
|
||||
|
||||
MarkdownBlock.defaultProps = {
|
||||
siteConfig: {}
|
||||
siteConfig: {},
|
||||
};
|
||||
|
||||
export default MarkdownBlock;
|
||||
|
|
|
@ -31,7 +31,7 @@ module.exports = (string, context = {}) => {
|
|||
.toLowerCase()
|
||||
// Handle accentuated characters
|
||||
.replace(new RegExp(`[${accents}]`, 'g'), c =>
|
||||
without.charAt(accents.indexOf(c))
|
||||
without.charAt(accents.indexOf(c)),
|
||||
)
|
||||
// Replace `.`, `(` and `?` with blank string like Github does
|
||||
.replace(/\.|\(|\?/g, '')
|
||||
|
|
|
@ -16,7 +16,7 @@ module.exports = function createBaseConfig(props, isServer) {
|
|||
sourceToMetadata,
|
||||
versionedDir,
|
||||
translatedDir,
|
||||
baseUrl
|
||||
baseUrl,
|
||||
} = props;
|
||||
|
||||
const config = new Config();
|
||||
|
@ -52,7 +52,7 @@ module.exports = function createBaseConfig(props, isServer) {
|
|||
.options({
|
||||
babelrc: false,
|
||||
presets: ['env', 'react'],
|
||||
plugins: [isServer ? 'dynamic-import-node' : 'syntax-dynamic-import']
|
||||
plugins: [isServer ? 'dynamic-import-node' : 'syntax-dynamic-import'],
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ module.exports = function createBaseConfig(props, isServer) {
|
|||
versionedDir,
|
||||
translatedDir,
|
||||
docsDir,
|
||||
sourceToMetadata
|
||||
sourceToMetadata,
|
||||
});
|
||||
|
||||
const cssRule = config.module.rule('css').test(/\.css$/);
|
||||
|
@ -103,15 +103,15 @@ module.exports = function createBaseConfig(props, isServer) {
|
|||
importLoaders: 1,
|
||||
localIdentName: `[local]_[hash:base64:8]`,
|
||||
sourceMap: !isProd,
|
||||
minimize: true
|
||||
minimize: true,
|
||||
});
|
||||
|
||||
// mini-css-extract plugin
|
||||
config.plugin('extract-css').use(CSSExtractPlugin, [
|
||||
{
|
||||
filename: isProd ? '[name].[chunkhash].css' : '[name].css',
|
||||
chunkFilename: isProd ? '[id].[chunkhash].css' : '[id].css'
|
||||
}
|
||||
chunkFilename: isProd ? '[id].[chunkhash].css' : '[id].css',
|
||||
},
|
||||
]);
|
||||
|
||||
if (isProd) {
|
||||
|
@ -122,10 +122,10 @@ module.exports = function createBaseConfig(props, isServer) {
|
|||
warnings: false,
|
||||
compress: false,
|
||||
ecma: 6,
|
||||
mangle: true
|
||||
mangle: true,
|
||||
},
|
||||
sourceMap: true
|
||||
})
|
||||
sourceMap: true,
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ module.exports = function(fileString) {
|
|||
versionedDir,
|
||||
docsDir,
|
||||
translatedDir,
|
||||
sourceToMetadata
|
||||
sourceToMetadata,
|
||||
} = options;
|
||||
|
||||
/* Extract content of markdown (without frontmatter) */
|
||||
|
|
|
@ -18,17 +18,17 @@ module.exports = function createServerConfig(props) {
|
|||
|
||||
// static site generator webpack plugin
|
||||
const docsLinks = Object.values(docsMetadatas).map(data => ({
|
||||
path: `${data.permalink}`
|
||||
path: `${data.permalink}`,
|
||||
}));
|
||||
const paths = [...docsLinks, ...pagesMetadatas].map(data => data.path);
|
||||
config.plugin('siteGenerator').use(staticSiteGenerator, [
|
||||
{
|
||||
entry: 'main',
|
||||
locals: {
|
||||
baseUrl: siteConfig.baseUrl
|
||||
baseUrl: siteConfig.baseUrl,
|
||||
},
|
||||
paths
|
||||
}
|
||||
paths,
|
||||
},
|
||||
]);
|
||||
|
||||
// show compilation progress bar and build time
|
||||
|
|
|
@ -23,5 +23,5 @@ function applyChainWebpack(userChainWebpack, config, isServer) {
|
|||
|
||||
module.exports = {
|
||||
applyConfigureWebpack,
|
||||
applyChainWebpack
|
||||
applyChainWebpack,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue