-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.js
100 lines (97 loc) · 2.58 KB
/
webpack.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
const path = require('path')
const webpack = require('webpack')
module.exports = function createWebpackConfig () {
const CWD = process.cwd()
const BUBLE_LOADER = {
loader: '@qubit/buble-loader',
options: {
objectAssign: 'Object.assign',
transforms: {
dangerousForOf: true,
dangerousTaggedTemplateString: true,
asyncAwait: false
}
}
}
const MANAGED_STYLES = /(placement|variation)[0-9-]*\.(css|less)$/
return {
entry: [
'webpack-hot-middleware/client?path=https://localhost:41337/__webpack_hmr&timeout=20000&reload=true&&noInfo=true&&quiet=true'
],
output: {
path: CWD,
publicPath: 'https://localhost:41337/',
filename: 'bundle.js'
},
bail: false,
amd: { jQuery: true },
devtool: '#source-map',
resolve: {
modules: [
CWD,
// Search symlinks node_modules as well - https://webpack-v3.jsx.app/configuration/resolve/#resolve-modules
'./node_modules',
path.join(__dirname, 'node_modules')
],
alias: { jquery: '@qubit/jquery' }
},
resolveLoader: {
modules: [
path.join(__dirname, 'loaders'),
path.join(__dirname, 'node_modules')
]
},
module: {
loaders: [
// global.js
{
test: /global\.js$/,
use: ['raw-loader']
},
// package.json
{
test: /\.json$/,
use: ['json-loader']
},
// Import placement and variation styles without injecting
{
test: MANAGED_STYLES,
use: [
'raw-loader',
'less-loader',
{
// Add variables to .less files
loader: 'experience-less',
options: {
variationMasterId: true,
experienceId: true,
placementId: true
}
}
]
},
// Auto inject package styles
{
test: /\.(css|less)$/,
exclude: [MANAGED_STYLES],
use: ['style-loader', 'raw-loader', 'less-loader']
},
{
include: [path.join(__dirname, 'src/client/serve-experience.js')],
use: ['entry']
},
// Compile javascript to buble and fix legacy css imports
{
test: /\.js$/,
exclude: [/global\.js/],
use: ['experience-css', BUBLE_LOADER]
}
]
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin()
]
}
}