-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.common.js
61 lines (58 loc) · 2.12 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
const path = require("path");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ConfigParser = require('wirecloud-config-parser');
const parser = new ConfigParser('src/config.xml');
const metadata = parser.getData();
module.exports = {
context: __dirname,
entry: './src/js/main.js',
output: {
path: path.resolve(__dirname, 'build/js'),
libraryTarget: 'umd',
filename: 'main.js',
chunkFilename: '[name].bundle.js',
publicPath: '/showcase/media/' + metadata.vendor + '/' + metadata.name + '/' + metadata.version + '/js/',
},
module: {
rules: [
{
test: /\.js/,
exclude: /node_modules/,
use: ['babel-loader']
},
{
test: /\.css$/,
include: [
path.resolve(__dirname, 'src/css'),
path.resolve(__dirname, 'node_modules/maplibre-gl/dist/'),
],
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /\.(png|svg|jpg|gif)$/,
use: {
loader: 'url-loader',
options: {
name: './dist/img/icon/[name].[ext]',
},
},
},
]
},
plugins: [
new CopyWebpackPlugin({
patterns: [
{ context: '', from: 'LICENSE', to: path.resolve(__dirname, 'build') },
{ context: 'src', from: '*', to: path.resolve(__dirname, 'build') },
{ context: 'src', from: 'doc/*', to: path.resolve(__dirname, 'build') },
{ context: 'src', from: 'images/*', to: path.resolve(__dirname, 'build') },
{ context: 'src', from: 'map/*', to: path.resolve(__dirname, 'build') },
{ context: 'src/contrib', from: 'gsi/*', to: path.resolve(__dirname, 'build/map') },
]
}),
new MiniCssExtractPlugin({
filename: '../css/style.css',
}),
]
}