Concatenate files with npm as build tool
You can also use the power of the shell to do what you want:
"scripts": {
"concat": "cat www/js/**/*.js > all.js"},
I am using concat-files
And I noticed there's also concatenate-files
Both are pretty simple.
Also note writing your own is pretty simple too:
var output = files.map((f)=>{
return fs.readFileSync(f).toString();
}).join(';')
fs.writeFileSync('dist/bundle.js', output)
Yep, concat is gone. I was looking at this as well while moving away from gulp to pure node and found the package to be missing.
As an alternative I am now using buildify. Might be a slight overkill, but it works.
var buildify = require('buildify');
var files = [
"./node_modules/moduleA/file1.js",
"./node_modules/moduleB/file2.js",
];
buildify()
.concat(files)
.save("./dist/www/scripts/init.min.js");
try this
var concat = require('concat')
concat(['a.css', 'b.css', 'c.css'], 'all.css')
https://www.npmjs.com/package/concat
and don't forget about npm install concat
By command
use concat-glob-cli
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"concat": "concat-glob-cli -f path/to/**/*.js -o bundle.js",
...
},
https://www.npmjs.com/package/concat-glob-cli