hanford / next-offline

make your Next.js application work offline using service workers via Google's workbox
https://github.com/hanford/next-offline
1.59k stars 111 forks source link

error during compilation #215

Closed electather closed 4 years ago

electather commented 4 years ago

hi , I tried adding this lib to my project but now when i try to compile my app i get the following error

[ error ] ./pages/_app.tsx
Module not found: Can't resolve '@Components/common/loading' in 'D:\Development\Projects\Ghazalgoo 2.0\web-client\pages'

and this does not seem to be related to this single component. when i deleted the component i got the next component import as an error Module not found: Can't resolve '@Components/common/modal' in 'D:\Development\Projects\Ghazalgoo 2.0\web-client\pages' i use typescript and absolute imports in my project import eg: import Loading from '@Components/common/loading';

i use the following next.config

const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");

const withPlugins = require("next-compose-plugins");
const withCSS = require("@zeit/next-css");
const withOffline = require("next-offline");

module.exports = withOffline(
  withPlugins(
    [
      [
        withCSS,
        {
          cssLoaderOptions: {
            url: false
          }
        }
      ]
    ],
    {
      webpack: (config, _options) => {
        if (config.resolve.plugins) {
          config.resolve.plugins.push(new TsconfigPathsPlugin());
        } else {
          config.resolve.plugins = [new TsconfigPathsPlugin()];
        }

        return config;
      },
      target: "serverless"
    }
  )
);

and i just used your now 1 server.js i made no modifications. ps. whole thing looks very promising. i really hope to get it to work. great job.

hanford commented 4 years ago

It might be worth trying to remove next-compose-plugins the two packages are known to not play nice together

https://github.com/hanford/next-offline/issues/69