|
1 | 1 | import * as webpack from 'webpack';
|
2 | 2 | import {LoaderConfig, PathsPlugin} from '../utilities/ts-path-mappings-webpack-plugin';
|
| 3 | +import { CliConfig } from './config'; |
3 | 4 |
|
4 | 5 | const path = require('path');
|
5 | 6 | const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
|
6 | 7 | const CopyWebpackPlugin = require('copy-webpack-plugin');
|
7 | 8 | const HtmlWebpackPlugin = require('html-webpack-plugin');
|
8 | 9 |
|
9 | 10 | export function getWebpackCommonConfig(projectRoot: string) {
|
| 11 | + const sourceDir = CliConfig.fromProject().defaults.sourceDir; |
| 12 | + |
10 | 13 | const awesomeTypescriptLoaderConfig: LoaderConfig | any = {
|
11 | 14 | useWebpackText: true,
|
12 | 15 | useForkChecker: true,
|
13 |
| - tsconfig: path.resolve(projectRoot, './src/tsconfig.json') |
| 16 | + tsconfig: path.resolve(projectRoot, `./${sourceDir}/tsconfig.json`) |
14 | 17 | }
|
15 | 18 |
|
16 | 19 | return {
|
17 | 20 | devtool: 'inline-source-map',
|
18 | 21 | resolve: {
|
19 | 22 | extensions: ['', '.ts', '.js'],
|
20 |
| - root: path.resolve(projectRoot, './src'), |
| 23 | + root: path.resolve(projectRoot, `./${sourceDir}`), |
21 | 24 | moduleDirectories: ['node_modules'],
|
22 | 25 | plugins: [
|
23 | 26 | new PathsPlugin(awesomeTypescriptLoaderConfig);
|
24 | 27 | ]
|
25 | 28 | },
|
26 | 29 | context: path.resolve(__dirname, './'),
|
27 | 30 | entry: {
|
28 |
| - main: [path.resolve(projectRoot, './src/main.ts')], |
29 |
| - vendor: path.resolve(projectRoot, './src/vendor.ts'), |
30 |
| - polyfills: path.resolve(projectRoot, './src/polyfills.ts') |
| 31 | + main: [path.resolve(projectRoot, `./${sourceDir}/main.ts`)], |
| 32 | + vendor: path.resolve(projectRoot, `./${sourceDir}/vendor.ts`), |
| 33 | + polyfills: path.resolve(projectRoot, `./${sourceDir}/polyfills.ts`) |
31 | 34 | },
|
32 | 35 | output: {
|
33 | 36 | path: path.resolve(projectRoot, './dist'),
|
@@ -70,7 +73,7 @@ export function getWebpackCommonConfig(projectRoot: string) {
|
70 | 73 | plugins: [
|
71 | 74 | new ForkCheckerPlugin(),
|
72 | 75 | new HtmlWebpackPlugin({
|
73 |
| - template: path.resolve(projectRoot, 'src/index.html'), |
| 76 | + template: path.resolve(projectRoot, `./${sourceDir}/index.html`), |
74 | 77 | chunksSortMode: 'dependency'
|
75 | 78 | }),
|
76 | 79 | new webpack.optimize.CommonsChunkPlugin({
|
|
0 commit comments