1 | const path = require('path');
|
2 | const fs = require('fs');
|
3 | const HtmlWebpackLoader = require('html-webpack-plugin');
|
4 | const webpack = require('webpack');
|
5 | const rootPath = process.cwd();
|
6 | const getStandardConfig = require('./webpack.config');
|
7 |
|
8 | const packageJsonPath = path.resolve(rootPath, 'package.json');
|
9 | if (!fs.existsSync(packageJsonPath)) { throw new Error('Unable to find the package.json file for this package.'); }
|
10 |
|
11 | const { name } = require(packageJsonPath);
|
12 |
|
13 | module.exports = (env, args) => {
|
14 | const standardConfig = getStandardConfig(env, args);
|
15 | return {
|
16 | ...standardConfig,
|
17 | context: rootPath,
|
18 | entry: './harnesses.ts',
|
19 | target: 'web',
|
20 | output: undefined,
|
21 | module: {
|
22 | rules: [
|
23 | ...standardConfig.module.rules,
|
24 | {
|
25 | test: /\.pug$/,
|
26 | loader: 'pug-loader',
|
27 | },
|
28 | ],
|
29 | },
|
30 | externals: [],
|
31 | plugins: [
|
32 | ...standardConfig.plugins,
|
33 | new HtmlWebpackLoader({
|
34 | title: `${name} harness`,
|
35 | template: path.resolve(__dirname, '../harness/harness.pug'),
|
36 | inject: 'head',
|
37 | }),
|
38 | new webpack.DefinePlugin({
|
39 | PACKAGE_NAME: `"${name}"`,
|
40 | }),
|
41 | ],
|
42 | resolve: {
|
43 | ...standardConfig.resolve,
|
44 | modules: [path.resolve(rootPath, 'node_modules'), 'node_modules'],
|
45 | symlinks: false,
|
46 | },
|
47 | devServer: {
|
48 | port: 1234,
|
49 | },
|
50 | };
|
51 | };
|