返回 marp
next.config.js
根目录 / website / next.config.js
1 const path = require('path')
2 const withBundleAnalyzer = require('@next/bundle-analyzer')({
3 enabled: !!process.env.ANALYZE,
4 })
5 const { devDependencies } = require('./package.json')
6
7 // Build test function to ignore devDependencies in client build
8 const ignoreIncludedPaths = Object.keys(devDependencies).map(
9 (m) => path.join(path.resolve(__dirname, '../node_modules'), m) + path.sep
10 )
11 const ignoreExcludedPaths = [require.resolve('@marp-team/marp-core/browser')]
12
13 const testToignoreDevDependenciesInClient = (id) =>
14 !ignoreExcludedPaths.some((p) => id.startsWith(p)) &&
15 ignoreIncludedPaths.some((p) => id.startsWith(p))
16
17 // Environments
18 const env = { BUILD_YEAR: new Date().getFullYear().toString() }
19 if (process.env.URL) env.NEXT_PUBLIC_HOST = process.env.URL // for Netlify's deploy preview
20
21 module.exports = withBundleAnalyzer({
22 env,
23 transpilePackages: [
24 'hast-util-sanitize',
25 'hast-util-whitespace',
26 'unist-util-is',
27 'unist-util-remove-position',
28 'unist-util-visit',
29 ],
30 webpack: (config, { isServer }) => {
31 config.module.rules.push({ test: /\.md$/, type: 'asset/source' })
32 config.module.rules.push({
33 test: /\.ya?ml$/,
34 type: 'json',
35 use: {
36 loader: 'yaml-loader',
37 options: { asJSON: true },
38 },
39 })
40 config.module.rules.push({
41 test: /\.svg$/,
42 use: '@svgr/webpack',
43 })
44
45 if (!isServer) {
46 config.module.rules.push({
47 test: testToignoreDevDependenciesInClient,
48 issuer: [__dirname],
49 use: 'null-loader',
50 })
51 }
52
53 return config
54 },
55 })
56
56 lines JAVASCRIPT