-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathwebpack.common.js
65 lines (57 loc) · 1.5 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
const path = require('path');
const Dotenv = require('dotenv-webpack');
const webpack = require('webpack');
const { Skeleton } = require('./webpack.skeleton');
const { ENV } = process.env;
// eslint-disable-next-line no-console
console.log(ENV);
const envPath = `./.env.${ENV}`;
const OUTPATH_MAP = {
dev: 'dist',
triliumTest: 'dist',
preview: 'docs',
prod: 'release',
};
let outputName = 'trilium-chat.js';
if (ENV === 'preview') {
outputName = 'trilium-chat.[fullhash].js';
}
const isBrowser = ['dev', 'preview'].includes(ENV);
const debug = ['dev', 'triliumTest'].includes(ENV);
const outPath = OUTPATH_MAP[ENV];
module.exports = {
entry: './src/main.js',
output: {
filename: outputName,
path: path.resolve(__dirname, outPath),
clean: true,
},
plugins: [
new webpack.DefinePlugin({
'process.env.IS_BROWSER': JSON.stringify(isBrowser),
'process.env.DEBUG': JSON.stringify(debug),
}),
new Dotenv({
path: envPath, // Path to .env file (this is the default)
}),
new Skeleton(),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src/'),
},
},
module: {
rules: [
{
test: /\.less$/i,
use: [
// compiles Less to CSS
'style-loader',
'css-loader',
'less-loader',
],
},
],
},
};