Jean-Yves Didier

multiple target for webpack

This diff is collapsed. Click to expand it.
......@@ -3,114 +3,161 @@ const jsdoc = require('jsdoc-webpack-plugin');
const copy = require('copy-webpack-plugin');
const eslint = require('eslint-webpack-plugin');
module.exports = {
experiments : {
outputModule: true
},
entry: {
'arcs' : {
import : './src/exports.js',
module.exports = [
{
name: "core",
experiments : {
outputModule: true
},
entry: {
'arcs' : {
import : './src/exports.js',
},
},
mode: 'none',
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build'),
library: {
type: 'module',
}
},
module: {
parser: {
javascript: {
commonjsMagicComments: true
}
}
},
plugins: [
new eslint({}),
new copy({
patterns: [
{ from :'src/arcs_browser.js', to: 'arcs_browser.js'},
{ from: 'src/arcs_node.mjs', to: 'arcs_node.mjs'}
]
})
]
},
mode: 'none',
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build'),
library: {
type: 'module',
}
},
module: {
parser: {
javascript: {
commonjsMagicComments: true
{
name: "core-min",
experiments : {
outputModule: true
},
entry: {
'arcs' : {
import : './src/exports.js',
},
},
mode: 'production',
output: {
filename: '[name].min.js',
path: path.resolve(__dirname, 'build'),
library: {
type: 'module',
}
},
module: {
parser: {
javascript: {
commonjsMagicComments: true
}
}
}
},
},
plugins: [
new jsdoc({
conf: 'docs/engine.conf.json',
destination: 'docs/engine',
template: 'docs/arcs',
}),
new jsdoc({
conf: 'docs/components.conf.json',
destination: 'docs/components',
template: 'docs/arcs',
}),
new copy({
patterns: [
{ 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!
]
}),
new eslint({})
]
};
{
name: "doc",
mode: "development",
entry: {},
plugins: [
new jsdoc({
conf: 'docs/engine.conf.json',
destination: 'docs/engine',
template: 'docs/arcs',
}),
new jsdoc({
conf: 'docs/components.conf.json',
destination: 'docs/components',
template: 'docs/arcs',
}),
]
},
{
name: "deps",
mode: "production",
entry: {},
plugins: [
new copy({
patterns: [
{ 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!
]
}),
]
}
];
......