forked from clappr/clappr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.base.js
83 lines (80 loc) · 2.19 KB
/
webpack.config.base.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
const path = require('path')
const webpack = require('webpack')
const DirectoryNamedWebpackPlugin = require('directory-named-webpack-plugin')
const webpackConfig = (config) => {
return {
devServer: {
contentBase: [
path.resolve(__dirname, 'public'),
],
disableHostCheck: true, // https://github.com/webpack/webpack-dev-server/issues/882
compress: true,
host: '0.0.0.0',
port: 8080
},
mode: config.mode,
devtool: config.devtool || 'source-maps',
optimization: config.optimization,
entry: path.resolve(__dirname, 'src/main.js'),
externals: config.externals,
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: [path.resolve(__dirname, './node_modules')]
},
{
test: /fonts\.css$/,
loaders: ['css-loader', 'postcss-loader'],
include: path.resolve(__dirname, 'src/components/core/public')
},
{
test: /\.scss$/,
loaders: ['style-loader?singleton=true', 'css-loader', 'postcss-loader', 'sass-loader?includePaths[]='
+ path.resolve(__dirname, './src/base/scss')
],
include: path.resolve(__dirname, 'src')
},
{
test: /\.(png|woff|eot|swf|cur|ttf)/,
loader: 'url-loader',
options: {
limit: 1,
publicPath: '<%=baseUrl%>/'
},
},
{
test: /\.svg/, loader: 'svg-inline-loader'
},
{
test: /\.html/, loader: 'html-loader?minimize=false'
},
...(config.rules || [])
],
},
resolve: {
alias: {
'clappr-zepto': 'clappr-zepto/zepto.js'
},
plugins: [
new DirectoryNamedWebpackPlugin(true),
],
modules: ['node_modules']
},
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: 'dist/',
filename: config.filename,
library: 'Clappr',
libraryTarget: 'umd'
},
plugins: [
new webpack.DefinePlugin({
VERSION: JSON.stringify(require('./package.json').version),
}),
...(config.plugins || [])
],
}
}
module.exports = webpackConfig