-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.dev.config.js
More file actions
74 lines (70 loc) · 1.76 KB
/
Copy pathwebpack.dev.config.js
File metadata and controls
74 lines (70 loc) · 1.76 KB
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
import path from 'path';
import { fileURLToPath } from 'url';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
console.log('process.env.NODE_ENV ' ,
process.env.NODE_ENV
)
export default {
entry: {
'scroll-frame-canvas': './src/index.ts',
'demo': './src/demo.ts',
},
output: {
path: path.resolve(__dirname, 'docs-dist'),
filename: '[name].esm.js',
library: { type: 'module' },
environment: { module: true },
publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
},
experiments: { outputModule: true },
module: {
rules: [
{
test: /\.ts$/,
use: {
loader: 'ts-loader', options: { configFile: 'tsconfig.docs.json' },
},
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.ts', '.js'],
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.resolve(__dirname, 'demo/index.html'),
chunks: ['demo'],
scriptLoading: 'module',
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, 'downloads'),
to: path.resolve(__dirname, 'docs-dist/downloads'),
},
],
}),
],
devtool: 'source-map',
mode: 'development',
target: ['web', 'es2020'],
devServer: {
static: [
{ directory: path.resolve(__dirname, 'downloads'), publicPath: '/downloads' },
{ directory: path.resolve(__dirname, 'docs-dist'), publicPath: '/docs-dist' },
],
open: '/',
port: 8080,
host: '0.0.0.0',
hot: true,
liveReload: true,
devMiddleware: {
writeToDisk: true,
},
},
};