packages/cli: prefix plugin serve paths with target instead of app

This commit is contained in:
Patrik Oldsberg
2020-04-23 11:10:58 +02:00
parent 79997ccf54
commit baaa1d2f34
2 changed files with 24 additions and 24 deletions
@@ -31,19 +31,19 @@ export function createConfig(paths: Paths): webpack.Configuration {
profile: false,
bail: false,
devtool: 'cheap-module-eval-source-map',
context: paths.appPath,
context: paths.targetPath,
entry: [
`${require.resolve('webpack-dev-server/client')}?/`,
require.resolve('webpack/hot/dev-server'),
paths.appDevEntry,
paths.targetDevEntry,
],
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
modules: ['node_modules', paths.appSrc],
modules: ['node_modules', paths.targetSrc],
plugins: [
new ModuleScopePlugin(
[paths.appSrc, paths.appDev],
[paths.appPackageJson],
[paths.targetSrc, paths.targetDev],
[paths.targetPackageJson],
),
],
},
@@ -52,7 +52,7 @@ export function createConfig(paths: Paths): webpack.Configuration {
{
test: /\.(tsx?|jsx?|mjs)$/,
enforce: 'pre',
include: [paths.appSrc, paths.appDev],
include: [paths.targetSrc, paths.targetDev],
use: {
loader: 'eslint-loader',
options: {
@@ -62,7 +62,7 @@ export function createConfig(paths: Paths): webpack.Configuration {
},
{
test: /\.(tsx?|jsx?|mjs)$/,
include: [paths.appSrc, paths.appDev],
include: [paths.targetSrc, paths.targetDev],
exclude: /node_modules/,
loader: 'ts-loader',
options: {
@@ -73,7 +73,7 @@ export function createConfig(paths: Paths): webpack.Configuration {
{
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/, /\.frag/, /\.xml/],
loader: 'url-loader',
include: paths.appAssets,
include: paths.targetAssets,
options: {
limit: 10000,
name: 'static/media/[name].[hash:8].[ext]',
@@ -99,15 +99,15 @@ export function createConfig(paths: Paths): webpack.Configuration {
},
plugins: [
new HtmlWebpackPlugin({
template: paths.appHtml,
template: paths.targetHtml,
}),
new ForkTsCheckerWebpackPlugin({
tsconfig: paths.appTsConfig,
tsconfig: paths.targetTsConfig,
eslint: true,
eslintOptions: {
parserOptions: {
project: paths.appTsConfig,
tsconfigRootDir: paths.appPath,
project: paths.targetTsConfig,
tsconfigRootDir: paths.targetPath,
},
},
reportFiles: ['**', '!**/__tests__/**', '!**/?(*.)(spec|test).*'],
+12 -12
View File
@@ -28,21 +28,21 @@ export function getPaths() {
return paths.resolveTarget(`${path}.js`);
};
let appHtml = paths.resolveTarget('dev/index.html');
if (!existsSync(appHtml)) {
appHtml = paths.resolveOwn('templates/serve_index.html');
let targetHtml = paths.resolveTarget('dev/index.html');
if (!existsSync(targetHtml)) {
targetHtml = paths.resolveOwn('templates/serve_index.html');
}
return {
appHtml,
appPath: paths.resolveTarget('.'),
appAssets: paths.resolveTarget('assets'),
appSrc: paths.resolveTarget('src'),
appDev: paths.resolveTarget('dev'),
appDevEntry: resolveTargetModule('dev/index'),
appTsConfig: paths.resolveTarget('tsconfig.json'),
appNodeModules: paths.resolveTarget('node_modules'),
appPackageJson: paths.resolveTarget('package.json'),
targetHtml,
targetPath: paths.resolveTarget('.'),
targetAssets: paths.resolveTarget('assets'),
targetSrc: paths.resolveTarget('src'),
targetDev: paths.resolveTarget('dev'),
targetDevEntry: resolveTargetModule('dev/index'),
targetTsConfig: paths.resolveTarget('tsconfig.json'),
targetNodeModules: paths.resolveTarget('node_modules'),
targetPackageJson: paths.resolveTarget('package.json'),
};
}