This repository has been archived by the owner on May 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
105 lines (100 loc) · 3.13 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const glob = require('glob');
/* eslint-enable @typescript-eslint/no-var-requires */
const integrationDevPath = path.resolve(
__dirname,
'packages/bundle-odoo-website-editor/odoo-integration.ts',
);
const mainConfig = {
mode: 'development',
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.ts$/,
use: [
{
loader: 'ts-loader',
options: { configFile: 'tsconfig.json' },
},
],
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.xml$/i,
use: ['text-loader'],
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: '/fonts',
publicPath: 'http://localhost:8080/fonts',
},
},
],
},
resolve: {
extensions: ['.ts', '.js'],
},
devServer: {
contentBase: './examples',
// Webpack check that the host is `0.0.0.0` by default. Disable that
// check to access the server from external devices.
disableHostCheck: true,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',
},
},
// We might require this configuration in the future to
// bundle the differents parts of the editor.
// We do not need the following configuration now.
//
// optimization: {
// splitChunks: {
// cacheGroups: {
// default: false,
// vendors: false,
// owl: {
// name: 'owl.lib',
// chunks: 'all',
// test: /owl/,
// },
// core: {
// name: 'core',
// chunks: 'all',
// test: /core/,
// },
// },
// },
// },
};
// -----------------------------------------------------------------------------
// Examples
// -----------------------------------------------------------------------------
/**
* Create an entry for each typescript file contained in the `examples` folder.
*/
const entries = glob.sync(__dirname + '/examples/**/*.ts').reduce((acc, file) => {
const fileKey = file.slice((__dirname + '/examples/').length, -3);
acc[fileKey] = file;
return acc;
}, {});
entries['odoo-integration'] = integrationDevPath;
const examplesConfig = {
...mainConfig,
entry: entries,
output: {
path: path.resolve(__dirname, 'build/examples'),
filename: '[name].js',
library: 'JWEditor',
},
};
module.exports = examplesConfig;