This repository has been archived by the owner on Jan 4, 2023. It is now read-only.
forked from plone/plone.app.mosaic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
73 lines (66 loc) · 1.87 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
const webpack = require('webpack');
const path = require('path');
const merge = require('webpack-merge');
const PlonePlugin = require('plonetheme-webpack-plugin');
const SITENAME = process.env.SITENAME || 'Plone';
const THEMENAME = process.env.THEMENAME || 'plone-mosaic';
const PATHS = {
src: path.join(__dirname, 'resources', 'src', THEMENAME),
build: path.join(__dirname, 'resources', 'theme', THEMENAME),
mosaic: path.join(
__dirname, 'src', 'plone', 'app', 'mosaic', 'browser', 'static')
};
const PLONE = new PlonePlugin({
portalUrl: 'http://localhost:8080/' + SITENAME,
publicPath: '/' + SITENAME + '/++theme++' + THEMENAME + '/',
sourcePath: PATHS.src,
debug: true // disable for more quiet output
});
const common = {
entry: {
'default': path.join(PATHS.src, 'default'),
'logged-in': path.join(PATHS.src, 'logged-in')
},
output: {
path: PATHS.build
},
devServer: {
outputPath: PATHS.build
},
resolve: {
extensions: ['', '.js', '.jsx'],
alias: {
'react': 'react', // override react shipped in Plone (example)
'mosaic': path.join(PATHS.mosaic, 'js', 'mosaic.pattern'), // Mosaic FS
'mosaic-url': path.join(PATHS.mosaic, 'js'),
'mosaic-base-url': path.join(PATHS.mosaic, 'js')
}
},
module: {
loaders: [
{ test: /\.jsx?$/,
loaders: ['babel?cacheDirectory'],
include: PATHS.src }
]
}
};
switch(path.basename(process.argv[1])) {
case 'webpack':
module.exports = merge(PLONE.production, common, {
resolve: {
alias: {
'react': 'react-lite', // (example)
'react-dom': 'react-lite' // (example)
}
}
});
break;
case 'webpack-dev-server':
module.exports = merge(PLONE.development, common, {
entry: [
path.join(PATHS.src, 'default'),
path.join(PATHS.src, 'logged-in')
]
});
break;
}