Can Sencha Cmd be tuned for newer js features or replaced by other minifiers/optimizers?
Or support coming with the latest versions anyway?
Since the version has not been clarified, I will describe for 4.2.6
Go to root of your project and run
npm init
Install babel:
npm install --save-dev babel-cli babel-preset-es2015
Add to your package.json run scripts:
"scripts" : {
"build-prod": "./node_modules/.bin/babel es6 -d app --comments=false --compact=true",
"build-debug": "./node_modules/.bin/babel es6 -d app --sourceMaps=true",
"watch": "./node_modules/.bin/babel es6 -d app --watch"
},
Move source code from app and app.js to another folder (for example call it es6)
mv app.js app
mv app es6
and create build.xml in root and paste new task into project tag:
<target name="-before-build">
<x-shell reloadprofile="true" dir="${basedir}">
npm run build-debug
</x-shell>
</target>
Related
I want to add a .env file in my React application.
The project wasn't created using Create React APP. And without Webpack.
I'm struggling to find a proper solution for this
For a easy solution you could try to use react-app-env.
You could folllow this simple guide. In brief:
install it:
yarn add --dev react-app-env (or npm install --save-dev react-app-env)
change the start and build scripts:
"scripts": {
"start": "react-app-env start'",
"build": "react-app-env build'",
"test": "react-app-env test'",
...
}
finally add at least two configuration files (on project root folder): development.env and production.env. By default development.env is used imported on npm start and npm test, and production.env on npm build.
I write a react app and tried to dockerized it.
after i do this it doesn't compile corectly, it doesn't find "sass" module and this is my error:
Failed to compile.
./src/index.scss (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-6-
1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--5-
oneOf-6-3!./node_modules/sass-loader/dist/cjs.js??ref--5-oneOf-6-4!./src/index.scss)
Cannot find module 'sass'
Require stack:
- /app/node_modules/sass-loader/dist/utils.js
- /app/node_modules/sass-loader/dist/index.js
- /app/node_modules/sass-loader/dist/cjs.js
- /app/node_modules/loader-runner/lib/loadLoader.js
- /app/node_modules/loader-runner/lib/LoaderRunner.js
- /app/node_modules/webpack/lib/NormalModule.js
- /app/node_modules/webpack/lib/NormalModuleFactory.js
- /app/node_modules/webpack/lib/Compiler.js
- /app/node_modules/webpack/lib/webpack.js
- /app/node_modules/react-scripts/scripts/start.js
and this is my dockerfile:
From node:14.16.1-alpine
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./
RUN npm install --silent
RUN npm install react-scripts#4.0.3 -g --silent
COPY . ./
CMD ["npm", "start"]
and I don't have docker-compose.
any solution?
I add this line to my docker file but it doesn't work and gets me same Error:
RUN npm install -g sass
To note! node-sass is deprecated as by now!
Warning: LibSass and Node Sass are deprecated. While they will continue to receive maintenance releases indefinitely, there are no plans to add additional features or compatibility with any new CSS or Sass features. Projects that still use it should move onto Dart Sass.
Instead you can see that Sass is followed on the Dart sass project!
react-scripts already moved that direction!
The used package now is sass! npm i -g sass or npm i sass --save-dev
If you go to npm sass page
This package is a distribution of Dart Sass, compiled to pure JavaScript with no native code or external dependencies. It provides a command-line sass executable and a Node.js API.
You can install Sass globally using npm install -g sass which will provide access to the sass executable. You can also add it to your project using npm install --save-dev sass. This provides the executable as well as a library.
What should be done
Install sass
Globally
npm i -g sass
or
Locally
npm i sass --save-dev
I personally prefer to always go with local installs! So that npm install will add it automatically! Sometimes too to maintain the versions per project!
And
App compilling and running after install!
old version of react scripts
If you are running on an old version that require node-sass!
Then you can Update to the latest version! And before that! You may like to remove node_modules and package-lock.json.
npm i react-scripts --save
After that npm install to install again the project dependencies
And you can go for installing sass step
npm cache clear --force
npm install sass
To be clear:
1st) try uninstalling it by using this command
npm uninstall node-sass
and then 2nd) try installing sass
npm install --save-dev sass
this worked for me when I was having issues installing sass on a project using create react app
I solve it!
you just need to add this line in to your "dockerfile" so when you build your docker image it should install sass automaticly:
RUN npm install -g sass
and in your "package.json" add this in the "dependencies" that it tells to program what we have in this case we mean we have the specific version of "sass":
"sass": "version number(example:^5.0.0)"
and add this in "scripts" part that tells to program how to work in this case I think it tells that for "scss" files whatch that file and recognize and open it like a "css":
"scss": "sass --whatch scss -o css"
Try install in your terminal this
npm install --save-dev node-sass
and restart your localhost by typing
npm start
Hit Enter on your prompt
After doing these steps make sure to check your dependency go into
package.json
and find
"devDependencies": {
"node-sass": "^yourversion" }
How to add support for SCSS and SCSS modules in Webpack
npm install --save-dev node-sass sass-loader style-loader css-loader mini-css-extract-plugin
Source: https://www.developerhandbook.com/webpack/how-to-configure-scss-modules-for-webpack/#how-to-add-support-for-scss-and-scss-modules-in-webpack
I am trying to deploy a 'hello world' react app to github pages but it's not working. instead i see 404.
I follow the steps here - https://create-react-app.dev/docs/deployment#github-pages-https-pagesgithubcom
first I created a repo on github called test-react-deploy and cloned it into ~/
than I created a new react app:
cd /tmp
npx create-react-app test-react-deploy
cd test-react-deploy
than I moved it's content (without the .git folder) into my application repo:
cp -r .gitignore node\_modules package.json public src yarn.lock ~/test-react-deploy
cd ~/test-react-deploy
I added the following lines to package.json:
"homepage": "https://oren.github.io/food",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
and I installed gh-pages:
npm install --save gh-pages
I pushed everything to github and deploy with:
npm run deploy
But I see 404 when I go to https://oren.github.io/food
(BTW, I don't have a folder called food in my github pages)
Thanks!
It seems you are creating your gh-page under your test-react-deploy project, so you should see what is happening here: https://oren.github.io/test-react-deploy/
For special reasons I want to share the package.json file between two folders web (the react app) and mobile:
▸ mobile/
▸ node_modules/
▾ web/
▸ public/
▸ src/
README.md
package-lock.json
package.json
yarn.lock
In my package.json file I've added this:
"web-start": "react-scripts start", under scripts. However, when I run it in the root folder (/Users/edmund/Documents/src/banana-client) I get this:
➜ banana-client git:(master) ✗ yarn web-start
yarn web-start v0.24.6
$ react-scripts start web
Could not find a required file.
Name: index.html
Searched in: /Users/edmund/Documents/src/banana-client/public
error Command failed with exit code 1.
Is there a way I can add a root directory?
For this particular use case, I would recommend you to go ahead with Yarn workspaces.
Using Yarn workspaces, you can have multiple projects inside a single repository with a main package.json file at root level that projects share and project level package.json that they don't share and use individually.
Running yarn install will install all your dependencies at the root level, which is configurable if you don't want some packages to install at root.
You can have scripts in root that can help you run internal projects in that workspace.
So your final project structure will look something like this:
- project_root
- web
- node_modules
- package.json
- mobile
- node_modules
- package.json
- node_modules
- package.json
Learn more about Yarn workspaces here: https://yarnpkg.com/lang/en/docs/workspaces/
Look at this example here to understand it's basic usage:
https://github.com/pedronauck/yarn-workspaces-example
I'd agree that Yarn workspaces may help you accomplish what you are after. Otherwise, you will have to eject as the configuration for the appIndexJs (set to /src/index.js) is set in config/paths.js in the react-scripts package. Once ejected, you can modify the config/paths.js variable appIndexJs to accommodate a varying appIndex.
Building on above answer just do:
"web-start": "cd web && npm start"
Adding this workaround solved the same problem for me:
"web-start": "cd web && react-scripts start"
Our applications uses webpack. I need all my tests to run and artifacts to be created by web pack;
In my package.json, "build" script is defined:
..
"build": "webpack --config webpack.config.prod.js -p"
..
and this is my gitlab-ci.yml for now:
image: iteamdev/node-webpack:latest
variables:
NODE_ENV: "development" # required, because we need to install devDependencies
stages:
- build
compile:
stage: build
script:
- npm -v
- npm install -qs # install all dependencies (and devDependencies)
- npm run build # run webpack, set NODE_ENV=production
artifacts:
paths:
- dist/
What options do I have for the "image"? Is the one i'm using good for my needs? Should I work with a specific version?
I'd probably recommend using image: node:4.2.2 for your image.