forked from michmech/xonomy
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.prod.js
69 lines (65 loc) · 1.51 KB
/
webpack.config.prod.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
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const commonOptions = {
entry: {
'xonomy': './src/xonomy.ts',
},
module: {
rules: [{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'ts-loader',
}, {
test: /\.s?css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: './'
}
},
'css-loader',
'sass-loader'
],
}]
},
output: {
// Path on disk for output file
path: path.resolve(__dirname, 'dist'),
// Path in webpack-dev-server for compiled files (has priority over disk files in case both exist)
publicPath: '/dist/',
},
resolve: {
extensions: ['.js', '.ts'], // enable autocompleting .ts and .js extensions when using import '...'
alias: {
// Enable importing source files by their absolute path by prefixing with "@/"
// Note: this also requires typescript to be able to find the imports (though it doesn't use them other than for type checking), see tsconfig.json
"@": path.join(__dirname, "src"),
}
},
plugins: [new MiniCssExtractPlugin()],
};
module.exports = [{
...commonOptions,
output: {
...commonOptions.output,
filename: '[name].umd.js',
library: {
// name: 'Xonomy',
type: 'umd',
umdNamedDefine: true,
// export: 'default', // use the default export of the library...
},
}
}, {
...commonOptions,
experiments: { outputModule: true },
output: {
...commonOptions.output,
filename: '[name].esm.js',
library: {
type: 'module'
}
}
},
]