-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.conf.base.js
66 lines (64 loc) · 1.75 KB
/
webpack.conf.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
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const project = require('./project.json');
const env = process.env.NODE_ENV || 'development';
function buildEntries(){
const entries = {}
project.scripts.source.libs.forEach(lib => {
entries[lib.name] = `${__dirname}/${lib.entry}`;
});
return entries;
}
module.exports = {
entry: buildEntries(),
output: {
library: '[name]',
libraryExport: 'default',
libraryTarget: 'umd'
},
externals: {
'angular': 'angular',
'@vue': 'Vue',
'react': 'React',
'react-dom': 'ReactDOM'
},
module: {
rules: [
{
test: /\.(styl|css)$/,
use: [ MiniCssExtractPlugin.loader, 'css-loader', 'stylus-loader' ]
},
{
test: /\.html$/,
include: [
path.resolve(__dirname, project.scripts.source.root.angular),
path.resolve(__dirname, project.scripts.source.root.vanilla),
path.resolve(__dirname, project.scripts.source.root.vue)
],
use: 'html-loader'
},
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
}
]
},
resolve: {
alias: {
'@vue$': 'vue/dist/vue.esm.js',
'@vue': `${__dirname}/${project.scripts.source.root.vue}`,
'@angular': `${__dirname}/${project.scripts.source.root.angular}`,
'@react': `${__dirname}/${project.scripts.source.root.react}`,
'@vanilla': `${__dirname}/${project.scripts.source.root.vanilla}`,
'@styles': `${__dirname}/${project.styles.source.root}`
}
},
plugins: [
new CopyWebpackPlugin([{
from: project.images.source.files,
to: project.images.dist.root
}])
]
}