Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into tailwindlabs-master
  • Loading branch information
huibizhang committed Oct 3, 2022
2 parents 343c54d + 175472c commit c73ccff
Show file tree
Hide file tree
Showing 174 changed files with 23,263 additions and 1,279 deletions.
45 changes: 22 additions & 23 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,15 @@ const fallbackGetStaticProps = {
module.exports = withBundleAnalyzer({
swcMinify: true,
pageExtensions: ['js', 'jsx', 'mdx'],
images: {
disableStaticImages: true,
experimental: {
esmExternals: false,
},
async redirects() {
return require('./redirects.json')
},
webpack(config, options) {
if (!options.dev && options.isServer) {
let originalEntry = config.entry

config.entry = async () => {
let entries = { ...(await originalEntry()) }
entries['scripts/build-rss'] = './src/scripts/build-rss.js'
return entries
}
}

config.module.rules.push({
test: /\.(png|jpe?g|gif|webp|avif|mp4)$/i,
test: /\.mp4$/i,
issuer: /\.(jsx?|tsx?|mdx)$/,
use: [
{
Expand Down Expand Up @@ -129,7 +119,7 @@ module.exports = withBundleAnalyzer({

// Remove the 3px deadzone for drag gestures in Framer Motion
config.module.rules.push({
test: /framer-motion/,
test: /node_modules\/framer-motion/,
use: createLoader(function (source) {
return source.replace(
/var isDistancePastThreshold = .*?$/m,
Expand Down Expand Up @@ -175,7 +165,7 @@ module.exports = withBundleAnalyzer({
],
})

let mdx = [
let mdx = (plugins = []) => [
{
loader: '@mdx-js/loader',
options: {
Expand All @@ -186,6 +176,7 @@ module.exports = withBundleAnalyzer({
withSyntaxHighlighting,
withNextLinks,
withSmartQuotes,
...plugins,
],
rehypePlugins: [withLinkRoles],
},
Expand Down Expand Up @@ -217,24 +208,31 @@ module.exports = withBundleAnalyzer({
config.module.rules.push({
test: /\.mdx$/,
resourceQuery: /rss/,
use: [options.defaultLoaders.babel, ...mdx],
use: [options.defaultLoaders.babel, ...mdx()],
})

config.module.rules.push({
test: /\.mdx$/,
resourceQuery: /preview/,
use: [
options.defaultLoaders.babel,
...mdx,
createLoader(function (src) {
if (src.includes('<!--more-->')) {
const [preview] = src.split('<!--more-->')
return preview
}

const [preview] = src.split('<!--/excerpt-->')
return preview.replace('<!--excerpt-->', '')
}),
...mdx([
() => (tree) => {
let firstParagraphIndex = tree.children.findIndex((child) => child.type === 'paragraph')
if (firstParagraphIndex > -1) {
tree.children = tree.children.filter((child, index) => {
if (child.type === 'import' || child.type === 'export') {
return true
}
return index <= firstParagraphIndex
})
}
},
]),
],
})

Expand All @@ -252,7 +250,7 @@ module.exports = withBundleAnalyzer({
source.replace(/export const/gs, 'const') + `\nMDXContent.layoutProps = layoutProps\n`
)
}),
...mdx,
...mdx(),
createLoader(function (source) {
let fields = new URLSearchParams(this.resourceQuery.substr(1)).get('meta') ?? undefined
let { attributes: meta, body } = frontMatter(source)
Expand Down Expand Up @@ -365,6 +363,7 @@ function getUtilities(plugin, { includeNegativeValues = false } = {}) {
addComponents: () => {},
corePlugins: () => true,
prefix: (x) => x,
config: (option, defaultValue) => (option ? defaultValue : { future: {} }),
addUtilities,
theme: (key, defaultValue) => dlv(defaultConfig.theme, key, defaultValue),
matchUtilities: (matches, { values, supportsNegativeValues } = {}) => {
Expand Down
Loading

0 comments on commit c73ccff

Please sign in to comment.