This repository has been archived by the owner on Aug 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.happo.js
46 lines (37 loc) · 1.47 KB
/
.happo.js
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
35
36
37
38
39
40
41
42
43
44
45
46
const path = require('path');
const { RemoteBrowserTarget } = require('happo.io');
const { findPagesDir } = require('next/dist/lib/find-pages-dir');
const nextWebpackConfig = require('next/dist/build/webpack-config').default;
const loadNextConfig = require('next/dist/next-server/server/config').default;
const happoTmpDir = './happo-tmp';
const webpack = require('next/dist/compiled/webpack/webpack');
webpack.init(true);
module.exports = {
targets: {
chrome: new RemoteBrowserTarget('chrome', { viewport: '600x400' }),
},
setupScript: path.resolve(__dirname, 'happoSetup.js'),
customizeWebpackConfig: async config => {
const nextConfig = await loadNextConfig('production', __dirname, null);
const base = await nextWebpackConfig(__dirname, {
config: nextConfig,
entrypoints: {},
pagesDir: findPagesDir(process.cwd()),
rewrites: { beforeFiles: [], afterFiles: [], fallback:[] },
});
config.plugins = base.plugins;
config.resolve = base.resolve;
config.resolveLoader = base.resolveLoader;
Object.keys(config.resolve.alias).forEach(key => {
if (!config.resolve.alias[key]) {
delete config.resolve.alias[key];
}
});
config.module = base.module;
return config;
},
webpack: webpack.webpack,
// Happo is unable to resolve some imports if the tmpdir isn't located inside
// the project structure. The default is an OS provided folder, `os.tmpdir()`.
tmpdir: path.join(__dirname, happoTmpDir),
};