Welcome Guest, Not a member yet? Register   Sign In
Recommended path for npm
#1

(This post was last modified: 07-13-2020, 05:37 AM by jreklund.)

What is the recommended path/folder for npm, that is root or public? 

In laravel framework, npm can be installed in the root and accessed by laravel mix. 

How can I do it here? Thank you.
Reply
#2

CodeIgniter dosen't have that kind of library, so you need to put your JS files in the public folder, for it to be accessible.
Reply
#3

@aswinkumar863 are you talking in terms of installing add-ons via npm such as :
npm install bootstrap
Reply
#4

(07-15-2020, 01:47 AM)captain-sensible Wrote: @aswinkumar863    are you talking in terms of installing add-ons via npm such as :
npm install bootstrap

Yes
Reply
#5

(This post was last modified: 07-19-2020, 12:44 PM by captain-sensible.)

ok  I will give you the quickish,  around the houses answer where i give you an example of installing gulp using npm.


I just used npm to install gulp  into a  new development directory called "appstarter"  yes i have no imagination but it keeps the reduces the amount of decisions.

I'm on Linux (slackware - of course :^) )
So i did a change directory to  (the root of the directory )   /var/www/htdocs/appstarter

I  did re-use  previous package.json i will put it here for perusal .

Code:
{
  "name": "CI4",
  "version": "1.0.0",
  "description": "sass & gulp",
  "main": "gulpfile.js",
  "dependencies": {
    "bootstrap": "^4.5.0",
    "browser-sync": "^2.26.10",
    "gulp-autoprefixer": "^6.1.0",
    "gulp-clean": "^0.4.0",
    "gulp-clean-css": "^4.3.0",
    "gulp-concat": "^2.6.1",
    "gulp-minify-css": "^1.2.4",
    "gulp-rename": "^1.4.0",
    "gulp-sass": "^4.1.0",
    "gulp-uglify": "^3.0.2"
  },
  "devDependencies": {
    "gulp": "^4.0.2",
    "gulp-sourcemaps": "^2.6.5"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "andy",
  "license": "ISC"
}

SO all i had to do was run :

Code:
npm install

which was done from the root of the appstarter dir



I put  a gulpfile.js also at the root ; so i simply take that into consideration with converting scss into css.

Couple of  things though; i'm a bit old school have known and previously used composer and begining to see the benefits when things need up dating. So you see "bootstrap": "^4.5.0"  in the package.json , well i decided to   use composer for the sass version of bootstrap which is :

Code:
composer require twbs/bootstrap


Also for me on Linux i needed to install nodejs

I first as root ran :
[CODE]
# npm install --global gulp-cli
[/CODE}
Reply
#6

(07-19-2020, 12:35 PM)captain-sensible Wrote: ok  I will give you the quickish,  around the houses answer where i give you an example of installing gulp using npm.


I just used npm to install gulp  into a  new development directory called "appstarter"  yes i have no imagination but it keeps the reduces the amount of decisions.

I'm on Linux (slackware - of course :^) )
So i did a change directory to  (the root of the directory )   /var/www/htdocs/appstarter

I  did re-use  previous package.json i will put it here for perusal .

Code:
{
  "name": "CI4",
  "version": "1.0.0",
  "description": "sass & gulp",
  "main": "gulpfile.js",
  "dependencies": {
    "bootstrap": "^4.5.0",
    "browser-sync": "^2.26.10",
    "gulp-autoprefixer": "^6.1.0",
    "gulp-clean": "^0.4.0",
    "gulp-clean-css": "^4.3.0",
    "gulp-concat": "^2.6.1",
    "gulp-minify-css": "^1.2.4",
    "gulp-rename": "^1.4.0",
    "gulp-sass": "^4.1.0",
    "gulp-uglify": "^3.0.2"
  },
  "devDependencies": {
    "gulp": "^4.0.2",
    "gulp-sourcemaps": "^2.6.5"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "andy",
  "license": "ISC"
}

SO all i had to do was run :

Code:
npm install

which was done from the root of the appstarter dir



I put  a gulpfile.js also at the root ; so i simply take that into consideration with converting scss into css.

Couple of  things though; i'm a bit old school have known and previously used composer and begining to see the benefits when things need up dating. So you see "bootstrap": "^4.5.0"  in the package.json , well i decided to   use composer for the sass version of bootstrap which is :

Code:
composer require twbs/bootstrap


Also for me on Linux i needed to install nodejs

I first as root ran :
[CODE]
# npm install --global gulp-cli
[/CODE}


If I am not wrong, you are using gulp to bundle the assets in the root directory and outputs it in public directory. So that you can access it. Seems Legit.
Reply
#7

(This post was last modified: 07-22-2020, 01:55 AM by captain-sensible.)

yes i install whats necessary so that when i am using command line and have cd'd into root of dev, running:

Code:
gulp task
//where task is the name of my function , works

For the last dev project i used composer; so the relative path from my dev root to bootstrap scss
is :
Code:
vendor/twbs/bootstrap/scss/

and o in mygulpfile.js i quote as the source for scss :
Code:
.src('vendor/twbs/bootstrap/scss/*.scss    ')/
then quote output in gulpfile
Code:
.pipe(gulp.dest('public/css'))

the result is that bootstrap sccs and custom sccss is converted to css and is put where i want it in public at /public/css

what i also do is use gitignore so that scss stuff is ignored. when i uploaded to live server i zipped needed directories which were only :
CI4
├── PHPMailer.zip
├── app.zip
├── public.zip

├── vendor.zip
└── writable.zip


I switched to using composer for bootstrap and also for CI4 to make it easier to update. I couldn't find anything pure and straight forward at https://packagist.org/ that i understood for gulp thats why i still use npm for that
Reply




Theme © iAndrew 2016 - Forum software by © MyBB