-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.common.js
79 lines (77 loc) · 1.66 KB
/
webpack.common.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
const path = require('path')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const cleanWebpackPlugin = require('clean-webpack-plugin')
const allSCSS = new ExtractTextPlugin('example/style.css')
const baseSCSS = new ExtractTextPlugin('main/js-tabs-base.css')
const extractTextConfig = {
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
sourceMap: true
}
},
{
loader: 'postcss-loader',
options: {
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
}
module.exports = {
entry: {
example: [
path.resolve('src', 'example', 'index.js')
],
main: [
'idempotent-babel-polyfill',
path.resolve('src', 'index.js')
]
},
output: {
path: path.resolve('dist'),
filename: path.join('[name]', 'index.js'),
library: 'JsTabs',
libraryTarget: 'umd'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.scss$/,
include: path.resolve('src', 'example'),
use: allSCSS.extract(extractTextConfig),
},
{
test: /\js-tabs-base.scss$/,
use: baseSCSS.extract(extractTextConfig),
}
]
},
plugins: [
new cleanWebpackPlugin('dist', {}),
allSCSS,
baseSCSS,
new HtmlWebpackPlugin({
inject: false,
hash: true,
template: path.resolve('src', 'example', 'index.html'),
filename: path.join('example', 'index.html')
})
]
}