-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
99 lines (95 loc) · 3.21 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
import path from 'path';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const sharedConfig = {
mode: 'development',
externals: {
fs: 'fs',
},
resolve: {
plugins: [
new TsconfigPathsPlugin({
mainFields: ['module', 'main'],
}),
],
enforceExtension: false,
enforceModuleExtension: false,
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /(\.ts|\.js)$/,
use: {
loader: 'babel-loader',
options: {
babelrc: false,
presets: [
'@babel/preset-typescript',
],
plugins: [
['module:@babel/plugin-proposal-decorators', { legacy: true }],
'module:@babel/plugin-proposal-class-properties',
'module:@babel/plugin-proposal-private-methods'
],
}
},
},
],
},
}
const devConfig = {
name: 'devserver',
...sharedConfig,
devServer: {
onAfterSetupMiddleware(server) {
server.app.get('/preview/examples/blog.bundle.js', (req, res) => {
return res.sendFile(`${process.cwd()}/dist/examples/blog.bundle.js`);
});
server.app.get('/*', (req, res) => {
return res.sendFile(`${process.cwd()}/public/blog.html`);
});
},
hot: false,
static: [
path.resolve(process.cwd(), 'public'),
path.resolve(process.cwd(), 'node_modules/qunitx/vendor'), // NOTE: make this work with qunitx in future
],
devMiddleware: {
writeToDisk: true
},
port: 1234
},
entry: {
'examples/basic': './examples/basic/index.ts',
'examples/blog': path.resolve(__dirname, './examples/blog/index.ts'),
'test/index': path.resolve(__dirname, './test/index.ts')
},
resolve: {
preferRelative: true,
extensions: ['.js', '.ts'],
alias: {
'@emberx/component/test': path.resolve(__dirname, 'packages/@emberx/component/test/index.ts'),
'@emberx/component': path.resolve(__dirname, 'packages/@emberx/component/src/index.ts'),
'@emberx/helper/test': path.resolve(__dirname, 'packages/@emberx/helper/test/index.ts'),
'@emberx/helper': path.resolve(__dirname, 'packages/@emberx/helper/src/index.ts'),
'@emberx/test-helpers/test': path.resolve(__dirname, 'packages/@emberx/test-helpers/test/index.ts'),
'@emberx/test-helpers': path.resolve(__dirname, 'packages/@emberx/test-helpers/src/index.ts'),
'@emberx/string/test': path.resolve(__dirname, 'packages/@emberx/string/test/index.ts'),
'@emberx/string': path.resolve(__dirname, 'packages/@emberx/string/src/index.ts'),
'@emberx/router/test': path.resolve(__dirname, 'packages/@emberx/router/test/index.ts'),
'@emberx/router': path.resolve(__dirname, 'packages/@emberx/router/src/index.ts')
}
},
// externals: {
// // Remove once we have new glimmer-vm version published. The duplicate version is from linking issues
// '@glimmer/validator': 'commonjs @glimmer/validator'
// },
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
},
}
export default [devConfig];