forked from deeptailor/openmct-as-a-dependency
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
103 lines (102 loc) · 3.08 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 path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { VueLoaderPlugin } = require("vue-loader");
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = {
entry: {
main: './src/index.js',
espressoTheme: './node_modules/openmct/src/plugins/themes/espresso-theme.scss'
},
mode: 'development',
devtool: 'eval-source-map',
output: {
filename: '[name].js',
library: '[name]',
libraryTarget: 'umd',
path: path.resolve(__dirname, 'dist')
},
resolve: {
alias: {
"@": path.join(__dirname, "node_modules/openmct"),
"openmct": path.join(__dirname, "node_modules/openmct/dist/openmct.js"),
"vue": path.join(__dirname, "node_modules/vue/dist/vue.js")
}
},
plugins: [
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[name].css'
}),
new CopyWebpackPlugin([
{
from: 'node_modules/openmct/src/images/favicons',
to: 'favicons'
},
{
from: 'dist/index.html',
transform: function (content) {
return content.toString().replace(/dist\//g, '');
}
}
])
],
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader'
},
// this will apply to both plain `.css` files
// AND `<style>` blocks in `.vue` files
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
]
},
{
test: /\.(sc|sa|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'fast-sass-loader'
]
},
{
test: /\.html$/,
use: 'html-loader'
},
{
test: /\.(jpg|jpeg|png|svg|ico|woff2?|eot|ttf)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath(url, resourcePath, context) {
if (/\.(jpg|jpeg|png|svg)$/.test(url)) {
return `images/${url}`
}
if (/\.ico$/.test(url)) {
return `icons/${url}`
}
if (/\.(woff2?|eot|ttf)$/.test(url)) {
return `fonts/${url}`
} else {
return `${url}`;
}
}
}
}
]
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
port: 9000,
},
};