-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
108 lines (107 loc) · 2.85 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
104
105
106
107
108
const path = require('path');
const WebpackShellPluginNext = require('webpack-shell-plugin-next');
const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin');
class WatchRunPlugin {
apply(compiler) {
compiler.hooks.watchRun.tap('WatchRun', (comp) => {
if (comp.modifiedFiles) {
const changedFiles = Array.from(
comp.modifiedFiles, (file) => `\n ${file}`).join('');
console.log('===============================');
console.log('FILES CHANGED:', changedFiles);
console.log('===============================');
}
});
}
}
const plugins = [];
plugins.push(new WatchRunPlugin());
plugins.push(new WebpackShellPluginNext({
onBuildStart: {
scripts: ['mkdir -p dist/ && npm run copy:html'],
// scripts: ['echo "===> Starting packing with WEBPACK 5"'],
blocking: true,
parallel: false,
},
// onDoneWatch: {
onBuildEnd: {
// scripts: ['ls'],
scripts: ['npm run optimize:inline'],
// scripts: ['npm run copy:html && npm run optimize:inline'],
// scripts: ['npm run optimize:inline'],
blocking: true,
parallel: false,
},
}));
plugins.push(
new ExtraWatchWebpackPlugin({
files: [
'src/app/dashboard/style.css',
'src/app/dashboard/style.scss',
'src/app/dashboard/index.html',
// 'src/**/*.css',
// 'src/**/*.json',
// 'src/**/*.svg',
// 'src/**/*.html',
],
// dirs: [ 'path/to/dir' ],
}));
module.exports = {
mode: 'development',
// stats: 'verbose',
devtool: 'inline-source-map',
entry: {
main: './src/app/dashboard/src/index.ts',
},
output: {
// path: path.resolve(__dirname, './src/app/dashboard'),
// path: path.resolve(__dirname, './dist'),
// path: path.resolve(__dirname, './dist'),
// publicPath: '/static/',
// publicPath: '/assets/',
filename: 'index.js',
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
plugins: plugins,
optimization: {
removeAvailableModules: false,
removeEmptyChunks: false,
splitChunks: false,
},
module: {
rules: [
// {
// test: /\.(scss|css)$/,
// use: ['style-loader', 'css-loader', 'sass-loader'],
// },
{
test: /\.tsx?$/,
loader: 'ts-loader',
// to slow?
// use: [
// {
// loader: 'ts-loader',
// options: {
// configFile: 'tsconfig.webpack.json',
// },
// },
// ],
// use: ['ts-loader'],
// loader: 'ts-loader?configFileName=tsconfig.webpack.json',
},
],
},
devServer: {
devMiddleware: {
writeToDisk: true,
},
static: [
{directory: path.join(__dirname, 'src/app/dashboard/static/')},
{directory: path.join(__dirname, 'src/app/dashboard/assets/')},
],
compress: true,
port: 4200,
},
};