Git Product home page Git Product logo

Comments (6)

koltyakov avatar koltyakov commented on June 16, 2024 1

There should be no such error.

Just loaded a blank new created starter project:

npx -p yo -p generator-sppp -c 'yo sppp'
npm run connect
npm run build
npm run publish
image

No messages in console with the exception of those produced by SharePoint.

UPD:

You're using npm run start, but it should be npm run build.

from generator-sppp.

Gennady-G avatar Gennady-G commented on June 16, 2024

Also can see this string in bundled app.js:

wp-2023-10-11_211104

from generator-sppp.

koltyakov avatar koltyakov commented on June 16, 2024

Hi @Gennady-G,

There is nothing special with the deployment. But one should never hardcode the URL, it's always relative and dynamic, based on the place it's run.

Same source code runs in a local workbench and production. You use context _spPageContextInfo.webAbsoluteUrl for the legacy SharePoint pages. See: https://github.com/koltyakov/sp-rest-proxy#load-page-context-helper.

When running a build and deploy commands, the relative path is build to host JS/CSS/cewp.html in site assets folder.

from generator-sppp.

koltyakov avatar koltyakov commented on June 16, 2024

Also, in CEWP you should have {{ publishPath }}:

image

If changed to something else, it won't be updated when bundling.

from generator-sppp.

Gennady-G avatar Gennady-G commented on June 16, 2024

Hi Andrew!
I haven't touched the publishPath..

Interesting - tried to recreate new test project from scratch (the only difference - I used spf2 folder)

1-2023-10-11_225445

Tried Your code with no hard-coded urls:

import { sp, Web } from "@pnp/sp";
import { loadPageContext } from "sp-rest-proxy/dist/utils/env";

import { loadContext } from "@utils/env";
import { logger } from "@utils/logger";
import { setupPnp } from "@utils/odata";

loadContext()
  .then(() => {
    setupPnp();

    const container = document.getElementById("example-cewp-container");

    if (container) {
      loadPageContext()
        .then(async () => {
          const web = new Web(_spPageContextInfo.webAbsoluteUrl);
          console.log(_spPageContextInfo);

          // test load items
          (async () => {
            
            const items = await web.lists.getByTitle("My list").items.select("Id", "FileLeafRef").filter("Id gt 7800").orderBy("Id", false).getAll();
            console.log(`Got ${items.length} items here`);

          })().catch((err) => {
            console.log(err);
          });
        })
        .catch(console.warn);
    }
  })
  .catch(logger.error);

npm run connect
npm run start
npm run publish

and this behaviour repeats. It works Ok but tries to relate with localhost:9090:

err-1-2023-10-11_231640
err-2-2023-10-11_231719
err-3-2023-10-11_232307

Am I right that this error is only "the noise" and does not affect final solution?

from generator-sppp.

Gennady-G avatar Gennady-G commented on June 16, 2024

You're using npm run start, but it should be npm run build.

Yes, You are right! Sorry for stupid questions) Thank You Andrew as usual! :-D

from generator-sppp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.