Jean-Yves Didier

finalized migration of the core library from bower + grunt to webpack

module.exports = function (grunt) {
"use strict";
let shim = function(obj) { return `\nexport default ${obj};\n`; };
// Project configuration.
grunt.initConfig({
terser: {
build: {
files: {
'build/arcs.min.js': [
'build/arcs.js'
],
'build/arcs_browser.min.js': [
'src/arcs_browser.js'
],
'build/arcseditor.min.js': [
'build/arcseditor.js'
]
}
}
},
bower: {
options : {
verbose: true,
targetDir: './deps',
copy: true,
cleanBowerDir: true,
layout: 'byComponent'
},
install : {
}
},
file_append: {
default_options: {
files: [
{
append: shim('AR'),
prepend: `import CV from '../cv/index.js';\n`,
input: './deps/aruco/index.js'
},
{
append: shim('CV'),
input: './deps/cv/index.js'
}
]
}
},
'string-replace': {
dist: {
files: {
'deps/objloader/objloader.js': 'deps/objloader/index.js',
'deps/mtlloader/mtlloader.js': 'deps/mtlloader/index.js',
'deps/ddsloader/ddsloader.js': 'deps/ddsloader/index.js'
},
options: {
replacements:[{
pattern: '../../../build/three.module.js',
replacement: '../three.js/index.js'
}]
}
}
},
concat: {
editor : {
src: [
'utils/editor/arcseditor.js',
'utils/editor/dragdrop.js',
'utils/editor/template.js',
'utils/editor/dialog.js',
'utils/editor/componentdialog.js',
'utils/editor/invocationdialog.js',
'utils/editor/connectiondialog.js'
],
dest: 'build/arcseditor.js'
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-jslint');
grunt.loadNpmTasks('grunt-terser');
grunt.loadNpmTasks('grunt-bower-task');
grunt.loadNpmTasks('grunt-file-append');
grunt.loadNpmTasks('grunt-string-replace');
// Default task(s).
grunt.registerTask('default', ['concat','copy','terser']);
grunt.registerTask('lint', ['jslint']);
grunt.registerTask('doc', ['jsdoc']);
grunt.registerTask('install-deps', ['bower', 'file_append', 'string-replace']);
};
{
"name": "ARCS",
"version": "0.2.0",
"description": "Augmented Reality Component System in web browser and node environment",
"main": "build/arcs.js",
"keywords": [
"Augmented",
"Reality"
],
"author": "Jean-Yves Didier",
"license": "GPL",
"dependencies": {
"tracking.js": "*",
"three.js": "https://raw.githubusercontent.com/mrdoob/three.js/r116/build/three.module.js",
"objloader" : "https://raw.githubusercontent.com/mrdoob/three.js/r116/examples/jsm/loaders/OBJLoader.js",
"mtlloader" : "https://raw.githubusercontent.com/mrdoob/three.js/r116/examples/jsm/loaders/MTLLoader.js",
"ddsloader" : "https://raw.githubusercontent.com/mrdoob/three.js/r116/examples/jsm/loaders/DDSLoader.js",
"aruco": "https://raw.githubusercontent.com/jcmellado/js-aruco/master/src/aruco.js",
"cv": "https://raw.githubusercontent.com/jcmellado/js-aruco/master/src/cv.js",
"codemirror" : "*",
"CodeMirror-htmlmixed": "https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/htmlmixed/htmlmixed.js",
"CodeMirror-javascript": "https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/javascript/javascript.js",
"md5" :"*"
}
}
......@@ -40,8 +40,70 @@ module.exports = {
}),
new copy({
patterns: [
{ from : 'src/arcs_browser.js', to: 'arcs_browser.js'},
{ from: 'src/arcs_node.mjs', to: 'arcs_node.mjs'}
{ from :'src/arcs_browser.js', to: 'arcs_browser.js'},
{ from: 'src/arcs_node.mjs', to: 'arcs_node.mjs'},
{ from: 'node_modules/tracking/build/tracking.js', to: '../deps/tracking/tracking.js'},
{ from: 'node_modules/three/build/three.module.js', to: '../deps/three.js/index.js'},
{
from: 'node_modules/three/examples/jsm/loaders/OBJLoader.js',
to: '../deps/objloader/index.js',
transform: function(content, path) {
return Buffer.from(content.toString().replace(
'../../../build/three.module.js',
'../three.js/index.js'
));
}
},
{
from: 'node_modules/three/examples/jsm/loaders/MTLLoader.js',
to: '../deps/mtlloader/index.js',
transform: function(content, path) {
return Buffer.from(content.toString().replace(
'../../../build/three.module.js',
'../three.js/index.js'
));
}
},
{
from: 'node_modules/three/examples/jsm/loaders/DDSLoader.js',
to: '../deps/ddsloader/index.js',
transform: function(content, path) {
return Buffer.from(content.toString().replace(
'../../../build/three.module.js',
'../three.js/index.js'
));
}
},
{
from: 'node_modules/js-aruco/src/aruco.js',
to: '../deps/aruco/index.js',
transform: function(content, path) {
return Buffer.from(content.toString()
.replace(
"var CV = require('./cv');",
"import CV from '../cv/index.js';"
)
.replace(
"module.exports = AR;",
"export default AR;"
)
);
}
},
{
from: 'node_modules/js-aruco/src/cv.js',
to: '../deps/cv/index.js',
transform: function(content, path) {
return Buffer.from(content.toString()
.replace(
"module.exports = CV;",
"export default CV;"
)
);
}
},
// TODO put here also files for dep directory.
// can also prepend content and replace strings using the transform property!
]
......@@ -49,3 +111,48 @@ module.exports = {
new eslint({})
]
};
/*** parts of gruntfile not processed yet
- minification with probably some custom targets
files: {
'build/arcs.min.js': [
'build/arcs.js'
],
'build/arcs_browser.min.js': [
'src/arcs_browser.js'
],
'build/arcseditor.min.js': [
'build/arcseditor.js'
]
}
- editor (to rebuild from scratch)
editor : {
src: [
'utils/editor/arcseditor.js',
'utils/editor/dragdrop.js',
'utils/editor/template.js',
'utils/editor/dialog.js',
'utils/editor/componentdialog.js',
'utils/editor/invocationdialog.js',
'utils/editor/connectiondialog.js'
],
dest: 'build/arcseditor.js'
}
***/
/*** parts of bower not processed yet
not sure if it is of any use
"codemirror" : "*",
"CodeMirror-htmlmixed": "https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/htmlmixed/htmlmixed.js",
"CodeMirror-javascript": "https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/javascript/javascript.js",
"md5" :"*"
***/
......