I am using nextjs framework and as UI framework I have chosen semantic-ui accompanied with semantic-ui-react.
The main reason for me choosing semantic-ui is the theming power of the framework.
I have installed the full package of semantic-ui as it being showed here.
`
semantic.json file has the following:
{
"base": "/client/static/semantic",
"paths": {
"source": {
"config": "src/theme.config",
"definitions": "src/definitions/",
"site": "src/site/",
"themes": "src/themes/"
},
"output": {
"packaged": "dist/",
"uncompressed": "dist/components/",
"compressed": "dist/components/",
"themes": "dist/themes/"
},
"clean": "dist/"
},
"permission": false,
"autoInstall": false,
"rtl": false,
"components": [blah blah],
"version": "2.2.10"
}
Theming is working properly on localhost.
The problem is the following: when trying to deploy usin now dependencies are being installed and semantic-ui feels like it is not there. That means there is no styling at all.
I am including semantic folder to my project (meaning, I am now gitignoring the /client/static/semantic folder).
What is the right way to deploy using Nextjs and semantic-ui?
**UPDATE:
Found where the problem comes from but still dont know how to solve it.
So the proccess goes like that when you theme your semantic-ui.
You install semantic-ui .
semantic-ui looks for the file semantic.json and knows you are theming.
Files and folder for theming are being created BUT not build. That means in order for the compoments of semantic-ui to be build it is needed to navigate to the specific semantic folder and run gulp build.
The problem is now dont know how to do this.
Any ideas?
So to close this with an answer from the comments.
In order to get pre-builds such as gulp/grunt/etc before the actual next build you have to create a script which does what you want.
Example:
// package.json
{
"scripts": {
"build": "gulp build && next build",
"start": "next start"
}
}
and just run npm run build to have your building process started.
Related
I inherited a react project that was working on my last computer. But now it can't build on my new computer. Specifically, I forgot how to get the npm start command to know where the project directory is.
For example, let's say I have the following two files:
// src/template/Page.js
import LoginComponent from 'component/Login.js'
// src/component/Login.js
export default function Gallery() { return <div></div>;}
Then when I run npm start, I get the error:
Module not found: Can't resolve 'component/Login.js' in 'src/template/Page.js'
I vaguely remember that on my last computer, I used some hidden file, or possibly the .env file to tell npm to look for all react components under the src/ directory, such that the term src/ can be omitted from all the import statements in the code.
Does anyone know how to tell react or npm to always import components without always spelling out the src/ prefix?
NOTE:
I also see a .vscode directory with these files:
// .vscode/settings.json
{
"editor.snippetSuggestions": "top",
"files.associations": {
"*.js": "javascriptreact"
},
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": false
},
"compilerOptions": {
"baseUrl": "src"
}
}
// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceRoot}/src"
}
]
}
I think these files might be related to my solution last time I got this working
In my package.json, I see these lines:
...
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
...
Also, my package.json says I'm using "react": "^16.6.1" and my npm -v shows 5.5.1. I don't remember what npm version I was using on my last computer. So not sure if that would matter.
You need a jsconfig.json to configure absolute imports (if you were using TypeScript, you would instead use tsconfig.json). This file is vital to your project working correctly, so you should commit this to source control so you don't have to remake it on each machine:
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}
I did not know Create React App supported this, I learned something today from your question. Thanks!
Finally got it work. I added this line to my .env file:
NODE_PATH=src
And then everything worked. Taken from documentation here: https://nodejs.org/api/modules.html
If the NODE_PATH environment variable is set to a colon-delimited list
of absolute paths, then Node.js will search those paths for modules if
they are not found elsewhere.
On Windows, NODE_PATH is delimited by semicolons (;) instead of
colons.
NODE_PATH was originally created to support loading modules from
varying paths before the current module resolution algorithm was
defined.
NODE_PATH is still supported, but is less necessary now that the
Node.js ecosystem has settled on a convention for locating dependent
modules. Sometimes deployments that rely on NODE_PATH show surprising
behavior when people are unaware that NODE_PATH must be set. Sometimes
a module's dependencies change, causing a different version (or even a
different module) to be loaded as the NODE_PATH is searched.
Additionally, Node.js will search in the following list of
GLOBAL_FOLDERS:
1: $HOME/.node_modules
2: $HOME/.node_libraries
3: $PREFIX/lib/node
Where $HOME is the user's home directory, and $PREFIX is the Node.js
configured node_prefix.
These are mostly for historic reasons.
It is strongly encouraged to place dependencies in the local
node_modules folder. These will be loaded faster, and more reliably.
Every time I install a new dependency with npm it's like cutting the read wire and hoping the bomb doesn't go off.
This error keeps coming up now:
[BABEL] React Refresh Babel transform should only be enabled in
development environment. Instead, the environment is: "dev_local". If
you want to override this check, pass {skipEnvCheck: true} as plugin
options.
It's a Gatsby app and I can't figure out how or where to achieve {skipEnvCheck: true} I've tried various things in gatsby-node.js such as:
exports.onCreateWebpackConfig = ({ actions, plugins }) => {
actions.setWebpackConfig({
plugins: [
plugins.define({
skipEnvCheck: true,
}),
],
});
};
But it doesn't help. I have different development .env configs (e.g. this "dev_local" environment) for testing with different settings and I want to keep doing that.
Or am I just chasing ghosts here and really there is some other problem with the dependencies?
I ran into the same error when attempting to deploy a Gatsby app to Heroku. A frustrating rabbit hole ensued, but I eventually narrowed the fix down to using gatsby serve instead of the default gatsby develop for the start script.
In package.json:
"scripts": {
"start": "gatsby serve --port $PORT --host 0.0.0.0",
"build": "gatsby build",
...
},
I have a react application created with create-react-app using react-data-grid#7. Since canary17 they started to use es2020 modules, to using the more recent builds I have to add support to optional-chaining and nullish-coalescing-operator to the app, otherwise I have errors starting the app.
After a few searchs, I installed customize-cra and react-app-rewired, changed the scripts commands to
"start": "react-app-rewired start"
"build": "react-app-rewired build"
and added this config-overrides.js
const {
override,
addBabelPlugin
} = require("customize-cra");
module.exports = override(
addBabelPlugin("#babel/plugin-proposal-optional-chaining"),
addBabelPlugin("#babel/plugin-proposal-nullish-coalescing-operator"),
);
Trying to run the app I obtain a strange behavior.
using the start command I obtaing the same error, but if I build and the deploy the app works correctly.
If I add something wrong in the config-overrides.js and try to start run start I received an error message, so I think the file is loaded.
Am I missing something?
After a few tests I found the solution changing from
addBabelPlugin("#babel/plugin-proposal-optional-chaining"),
addBabelPlugin("#babel/plugin-proposal-nullish-coalescing-operator"),
to
addExternalBabelPlugin(["#babel/plugin-proposal-optional-chaining", { "loose": false }]),
addExternalBabelPlugin(["#babel/plugin-proposal-nullish-coalescing-operator", { "loose": false }]),
I added the loose parameter too, but it was not the problem. now looks like works both in serve and build
I have built an application using the create-react-app version 2.0 locally. It runs, builds and works as expected. I am trying to deploy it to Zeit, using now. It works fine when I run the now command from withing the generated ./build folder (npm run build's destination).
My goal is to integrate it with GitHub so it updates the deployment on git push. Unfortunately, running now at the project's root folder doesn't work. I have a now.json file with the following contents:
{
"version": 2,
"name": "somename",
"builds": [
{
"src": "package.json",
"use": "#now/static-build"
}
],
"routes": [
{
"src": "^/static/(.*)",
"dest": "/static/$1"
},
{
"src": ".*",
"dest": "/index.html"
}
]
}
and my package.json contains the "now-build": "serve --single ./build" script.
The error
Every build attempt from the root folder results to this error:
Tries
I have tried changing the now-build to now-start and it didn't work, as it specifically needs now-build, I have tried removing the now.json altogether and it didn't work and every YouTube video I found on the issue doesn't do anything different but it works for them.
Any ideas?!
It turns out that the build command is wrong. The correct one is:
"now-build": "npm run build && mv build dist" in the package.json.
More info: https://github.com/zeit/now-examples/tree/master/create-react-app
This question is related to this SO post. I'm using create-react-app CLI for my project. It is a small scale web app which I start (locally) by npm start and it appears on browser. Now I need to generate a bundle.js file of my entire web app so that it can be used with Adobe Phonegap. How do I do that with my existing app?
react-scripts build should do it. Add a build field to the scripts section of your package.json file and then run npm run build. Example:
{
"repository": {
...
},
...
"dependencies": {
...
}
"scripts" : {
...
"build" : "react-scripts build"
}
}