-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.ts
34 lines (30 loc) · 911 Bytes
/
gatsby-node.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { GatsbyNode } from 'gatsby'
import type Webpack from 'webpack'
import CleanTerminalPlugin from 'clean-terminal-webpack-plugin'
import path from 'path'
import fs from 'fs'
const appDirectory = fs.realpathSync(process.cwd())
const resolveApp = (relativePath: string) => path.resolve(appDirectory, relativePath)
const paths = {
appSrc: resolveApp('src'),
appNodeModules: resolveApp('node_modules'),
}
export const onCreateWebpackConfig: GatsbyNode['onCreateWebpackConfig'] = ({ actions }) => {
const config: Webpack.Configuration = {
plugins: [new CleanTerminalPlugin()],
module: {
rules: [
{
enforce: 'pre',
test: /\.tsx?$/,
exclude: /node_modules/,
use: ['eslint-loader'],
},
],
},
resolve: {
modules: ['node_modules', paths.appNodeModules, paths.appSrc],
},
}
actions.setWebpackConfig(config)
}