Skip to content

Commit

Permalink
fix(demo): get happo working locally
Browse files Browse the repository at this point in the history
  • Loading branch information
williaster committed Jan 5, 2023
1 parent 66c9ff3 commit 9083cf1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/visx-demo/.happo.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
const { RemoteBrowserTarget } = require('happo.io');
const { findPagesDir } = require('next/dist/lib/find-pages-dir');
const getWebpackConfig = require('next/dist/build/webpack-config').default;
const loadNextConfig = require('next/dist/next-server/server/config').default;
const getBaseWebpackConfig = require('next/dist/build/webpack-config').default;
const loadNextConfig = require('next/dist/server/config').default;
const webpack = require('next/dist/compiled/webpack/webpack');
const path = require('path');

const trace = require('next/dist/telemetry/trace');
const nextBuildSpan = trace.trace('next-build');

const { asyncTimeout } = require('./.happo-variables');

webpack.init(true);
Expand Down Expand Up @@ -44,11 +47,12 @@ module.exports = {
// https://github.com/happo/happo-next-demo
customizeWebpackConfig: async (config) => {
const nextConfig = await loadNextConfig('production', __dirname, null);
const base = await getWebpackConfig(__dirname, {
const base = await getBaseWebpackConfig(__dirname, {
config: nextConfig,
entrypoints: {},
pagesDir: findPagesDir(process.cwd()),
rewrites: { beforeFiles: [], afterFiles: [], fallback: [] },
runWebpackSpan: nextBuildSpan,
});
config.plugins = base.plugins;
config.resolve = base.resolve;
Expand All @@ -62,6 +66,9 @@ module.exports = {
return config;
},

// use webpack from next.js
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),
Expand Down

0 comments on commit 9083cf1

Please sign in to comment.