forked from sfcc-solutions-share/composable-react-pd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.harness.config.js
115 lines (109 loc) · 3.09 KB
/
webpack.harness.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
106
107
108
109
110
111
112
113
114
115
/**
* This separate config is required as webpack-dev-middleware in PWA does not seem to support emitting files
*/
const config = require('@salesforce/pwa-kit-dev/configs/webpack/config')
const path = require('path')
const webpack = require('webpack')
// Add your customizations here
const clientConfig = config.find((cnf) => cnf.name === 'client')
// leverage the same CSS loader as PWA webpack does
const css = {
test: /\.css$/i,
exclude: /node_modules/,
use: [
// The `injectType` option can be avoided because it is default behaviour
'css-loader'
]
}
clientConfig.module.rules.push(css)
// start with pwa kits config and adapt
const cartridgeConfig = Object.assign({}, clientConfig, {
name: 'harness',
entry: {
harness: './cartridges/app_q_pwa_support/cartridge/client/default/js/harness.js'
},
devtool: 'source-map',
stats: {
...clientConfig.stats,
all: true
},
resolve: {
...clientConfig.resolve,
alias: {
...clientConfig.resolve.alias,
pwa: path.resolve(__dirname, 'app')
}
},
output: {
publicPath: 'auto',
path: path.resolve(
__dirname,
'./cartridges/app_q_pwa_support/cartridge/static/default/js/composable'
),
filename: '[name].js',
chunkLoadingGlobal: 'harnessChunkLoading'
},
optimization: {},
performance: {},
plugins: [
new webpack.DefinePlugin({
DEBUG: true,
'process.env.NODE_ENV': JSON.stringify('development'),
WEBPACK_TARGET: JSON.stringify('web')
})
],
devServer: {
devMiddleware: {
writeToDisk: true
}
}
})
const editorsConfig = {
mode: 'development',
devtool: 'source-map',
entry: {
einstein: path.resolve(
'./cartridges/app_q_pwa_support/cartridge/client/default/experience/editors/einstein.jsx'
),
codeeditor: path.resolve(
'./cartridges/app_q_pwa_support/cartridge/client/default/experience/editors/codeeditor.js'
),
styleEditor: path.resolve(
'./cartridges/app_q_pwa_support/cartridge/client/default/experience/editors/styleEditor.js'
)
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx']
},
output: {
path: path.resolve(
'./cartridges/app_q_pwa_support/cartridge/static/default/experience/editors'
),
filename: '[name].js'
},
plugins: [],
module: {
rules: [
{
test: /\.jsx?$/,
use: {
loader: 'babel-loader',
options: {}
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(svg|gif|jpe?g|png)$/,
use: 'file-loader?limit=10000'
},
{
test: /\.tsx?$/,
loader: 'ts-loader'
}
]
}
}
module.exports = [cartridgeConfig, editorsConfig]