-
Notifications
You must be signed in to change notification settings - Fork 8
/
webpack.config.js
103 lines (100 loc) · 2.95 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
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const index = `${__dirname}/index.html`;
const demo = `${__dirname}/demo/demo.js`;
const eventing = `${__dirname}/demo/eventing.js`;
const component = `${__dirname}/index.js`;
const icons = `${__dirname}/node_modules/@pearson-components/elements-sdk/build/icons/p-icons-sprite-1.1.svg`;
const elements = `${__dirname}/node_modules/@pearson-components/elements-sdk/build/css/elements.css`;
const fontsDir = `${__dirname}/node_modules/@pearson-components/elements-sdk/build/fonts/`;
const fonts = fs.readdirSync(fontsDir, 'utf-8').map(font => fontsDir + font);
// demo : [ 'babel-polyfill', demo ],
module.exports = {
entry: {
demo : [ demo ],
dev : [ elements, icons ],
eventInterface : [ eventing ],
dist : [ component ],
fonts : fonts
},
output: {
path : path.resolve(__dirname, 'build'),
filename : '[name].contextual-help.js',
publicPath : '/contextual-help/',
libraryTarget : 'umd'
},
devtool: "source-map",
devServer: {
host : "0.0.0.0",
port : 8081,
publicPath : "/contextual-help/",
hot : true,
https : false,
overlay : true,
watchContentBase : true,
disableHostCheck : true,
historyApiFallback : true,
watchOptions : { poll: true },
contentBase : path.join(__dirname, "build")
},
externals: [
{
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
},
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom'
}
}
],
module: {
rules: [
{
test: /\.(css|scss)$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "sass-loader"
}]
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '/images/[name].[ext]?[hash]'
}
},
{
test: /\.(ttf|woff|woff2)$/,
loader: 'file-loader',
options: {
name: '/fonts/[name].[ext]?[hash]'
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './demo/index.html'
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV' : JSON.stringify(process.env.NODE_ENV)
}),
new webpack.NamedModulesPlugin()
]
};