-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.dev.js
48 lines (47 loc) · 1.41 KB
/
webpack.dev.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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const { HotModuleReplacementPlugin } = require('webpack');
const { env } = require('process');
const getWebpackModule = require('./webpack.util');
module.exports = (config) => {
let entry = 'index-dev.tsx';
let dir = config.dir || env.dir;
let version = require(`./src/${dir}/version`);
let packageName = dir.split('/').pop().replaceAll('-', '_');
let useShadowDom = true;
let customBuild = config.customBuild || env.custom_build;
if (customBuild) {
useShadowDom = false;
}
const directory = 'src/' + (customBuild ? `${customBuild}/${dir}` : dir);
return {
devtool: 'source-map',
entry: path.resolve(directory, entry),
output: {
path: path.resolve(directory, 'dist'),
filename: 'index_bundle.js',
publicPath: '/',
},
mode: 'development',
module: getWebpackModule(packageName, version, useShadowDom),
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(directory, 'index.html'),
}),
new HotModuleReplacementPlugin(),
new ESLintPlugin({
extensions: ['ts', 'tsx', 'js', 'jsx'],
emitError: true,
emitWarning: false,
failOnError: true,
}),
],
resolve: {
extensions: ['.js', '.ts', '.tsx', '.jsx', '.css', '.scss'],
alias: {
environment$: path.resolve(__dirname, 'environment/environment.dev.ts'),
},
},
};
};