UNPKG

1.44 kBJavaScriptView Raw
1const path = require('path');
2const fs = require('fs');
3const HtmlWebpackLoader = require('html-webpack-plugin');
4const webpack = require('webpack');
5const rootPath = process.cwd();
6const getStandardConfig = require('./webpack.config');
7
8const packageJsonPath = path.resolve(rootPath, 'package.json');
9if (!fs.existsSync(packageJsonPath)) { throw new Error('Unable to find the package.json file for this package.'); }
10
11const { name } = require(packageJsonPath);
12
13module.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: [], // include node_modules
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};