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'); ...@@ -3,114 +3,161 @@ const jsdoc = require('jsdoc-webpack-plugin');
3 const copy = require('copy-webpack-plugin'); 3 const copy = require('copy-webpack-plugin');
4 const eslint = require('eslint-webpack-plugin'); 4 const eslint = require('eslint-webpack-plugin');
5 5
6 -module.exports = { 6 +module.exports = [
7 - experiments : { 7 + {
8 - outputModule: true 8 + name: "core",
9 - }, 9 + experiments : {
10 - entry: { 10 + outputModule: true
11 - 'arcs' : {
12 - import : './src/exports.js',
13 }, 11 },
12 + entry: {
13 + 'arcs' : {
14 + import : './src/exports.js',
15 + },
16 + },
17 + mode: 'none',
18 + output: {
19 + filename: '[name].js',
20 + path: path.resolve(__dirname, 'build'),
21 + library: {
22 + type: 'module',
23 + }
24 + },
25 + module: {
26 + parser: {
27 + javascript: {
28 + commonjsMagicComments: true
29 + }
30 + }
31 + },
32 + plugins: [
33 + new eslint({}),
34 + new copy({
35 + patterns: [
36 + { from :'src/arcs_browser.js', to: 'arcs_browser.js'},
37 + { from: 'src/arcs_node.mjs', to: 'arcs_node.mjs'}
38 + ]
39 + })
40 + ]
14 }, 41 },
15 - mode: 'none', 42 + {
16 - output: { 43 + name: "core-min",
17 - filename: '[name].js', 44 + experiments : {
18 - path: path.resolve(__dirname, 'build'), 45 + outputModule: true
19 - library: { 46 + },
20 - type: 'module', 47 + entry: {
21 - } 48 + 'arcs' : {
22 - }, 49 + import : './src/exports.js',
23 - module: { 50 + },
24 - parser: { 51 + },
25 - javascript: { 52 + mode: 'production',
26 - commonjsMagicComments: true 53 + output: {
54 + filename: '[name].min.js',
55 + path: path.resolve(__dirname, 'build'),
56 + library: {
57 + type: 'module',
58 + }
59 + },
60 + module: {
61 + parser: {
62 + javascript: {
63 + commonjsMagicComments: true
64 + }
27 } 65 }
28 - } 66 + },
29 }, 67 },
30 - plugins: [ 68 + {
31 - new jsdoc({ 69 + name: "doc",
32 - conf: 'docs/engine.conf.json', 70 + mode: "development",
33 - destination: 'docs/engine', 71 + entry: {},
34 - template: 'docs/arcs', 72 + plugins: [
35 - }), 73 + new jsdoc({
36 - new jsdoc({ 74 + conf: 'docs/engine.conf.json',
37 - conf: 'docs/components.conf.json', 75 + destination: 'docs/engine',
38 - destination: 'docs/components', 76 + template: 'docs/arcs',
39 - template: 'docs/arcs', 77 + }),
40 - }), 78 + new jsdoc({
41 - new copy({ 79 + conf: 'docs/components.conf.json',
42 - patterns: [ 80 + destination: 'docs/components',
43 - { from :'src/arcs_browser.js', to: 'arcs_browser.js'}, 81 + template: 'docs/arcs',
44 - { from: 'src/arcs_node.mjs', to: 'arcs_node.mjs'}, 82 + }),
45 - { from: 'node_modules/tracking/build/tracking.js', to: '../deps/tracking/tracking.js'}, 83 + ]
46 - { from: 'node_modules/three/build/three.module.js', to: '../deps/three.js/index.js'}, 84 + },
47 - { 85 + {
48 - from: 'node_modules/three/examples/jsm/loaders/OBJLoader.js', 86 + name: "deps",
49 - to: '../deps/objloader/index.js', 87 + mode: "production",
50 - transform: function(content, path) { 88 + entry: {},
51 - return Buffer.from(content.toString().replace( 89 + plugins: [
52 - '../../../build/three.module.js', 90 + new copy({
53 - '../three.js/index.js' 91 + patterns: [
54 - )); 92 + { from: 'node_modules/tracking/build/tracking.js', to: '../deps/tracking/tracking.js'},
55 - } 93 + { from: 'node_modules/three/build/three.module.js', to: '../deps/three.js/index.js'},
56 - }, 94 + {
57 - { 95 + from: 'node_modules/three/examples/jsm/loaders/OBJLoader.js',
58 - from: 'node_modules/three/examples/jsm/loaders/MTLLoader.js', 96 + to: '../deps/objloader/index.js',
59 - to: '../deps/mtlloader/index.js', 97 + transform: function(content, path) {
60 - transform: function(content, path) { 98 + return Buffer.from(content.toString().replace(
61 - return Buffer.from(content.toString().replace( 99 + '../../../build/three.module.js',
62 - '../../../build/three.module.js', 100 + '../three.js/index.js'
63 - '../three.js/index.js' 101 + ));
64 - )); 102 + }
65 - } 103 + },
66 - }, 104 + {
67 - { 105 + from: 'node_modules/three/examples/jsm/loaders/MTLLoader.js',
68 - from: 'node_modules/three/examples/jsm/loaders/DDSLoader.js', 106 + to: '../deps/mtlloader/index.js',
69 - to: '../deps/ddsloader/index.js', 107 + transform: function(content, path) {
70 - transform: function(content, path) { 108 + return Buffer.from(content.toString().replace(
71 - return Buffer.from(content.toString().replace( 109 + '../../../build/three.module.js',
72 - '../../../build/three.module.js', 110 + '../three.js/index.js'
73 - '../three.js/index.js' 111 + ));
74 - )); 112 + }
75 - } 113 + },
76 - }, 114 + {
77 - { 115 + from: 'node_modules/three/examples/jsm/loaders/DDSLoader.js',
78 - from: 'node_modules/js-aruco/src/aruco.js', 116 + to: '../deps/ddsloader/index.js',
79 - to: '../deps/aruco/index.js', 117 + transform: function(content, path) {
80 - transform: function(content, path) { 118 + return Buffer.from(content.toString().replace(
81 - return Buffer.from(content.toString() 119 + '../../../build/three.module.js',
82 - .replace( 120 + '../three.js/index.js'
83 - "var CV = require('./cv');", 121 + ));
84 - "import CV from '../cv/index.js';" 122 + }
85 - ) 123 + },
86 - .replace( 124 + {
87 - "module.exports = AR;", 125 + from: 'node_modules/js-aruco/src/aruco.js',
88 - "export default AR;" 126 + to: '../deps/aruco/index.js',
89 - ) 127 + transform: function(content, path) {
90 - ); 128 + return Buffer.from(content.toString()
91 - } 129 + .replace(
92 - }, 130 + "var CV = require('./cv');",
93 - { 131 + "import CV from '../cv/index.js';"
94 - from: 'node_modules/js-aruco/src/cv.js', 132 + )
95 - to: '../deps/cv/index.js', 133 + .replace(
96 - transform: function(content, path) { 134 + "module.exports = AR;",
97 - return Buffer.from(content.toString() 135 + "export default AR;"
98 - .replace( 136 + )
99 - "module.exports = CV;", 137 + );
100 - "export default CV;" 138 + }
101 - ) 139 + },
102 - ); 140 + {
103 - } 141 + from: 'node_modules/js-aruco/src/cv.js',
104 - }, 142 + to: '../deps/cv/index.js',
105 - 143 + transform: function(content, path) {
106 - 144 + return Buffer.from(content.toString()
107 - // TODO put here also files for dep directory. 145 + .replace(
108 - // can also prepend content and replace strings using the transform property! 146 + "module.exports = CV;",
109 - ] 147 + "export default CV;"
110 - }), 148 + )
111 - new eslint({}) 149 + );
112 - ] 150 + }
113 -}; 151 + },
152 +
153 +
154 + // TODO put here also files for dep directory.
155 + // can also prepend content and replace strings using the transform property!
156 + ]
157 + }),
158 + ]
159 + }
160 +];
114 161
115 162
116 163
......