mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 01:58:29 +00:00
aspnet-webpack module now preserves 'path' and 'publicPath' config settings when invoking Webpack compiler. Fixes #176.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aspnet-webpack",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "Helpers for using Webpack in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// that your loader plugins (e.g., require('./mystyles.less')) work in exactly the same way on the server as
|
||||
// on the client.
|
||||
import 'es6-promise';
|
||||
import * as path from 'path';
|
||||
import * as webpack from 'webpack';
|
||||
import { requireNewCopy } from './RequireNewCopy';
|
||||
|
||||
@@ -40,7 +41,15 @@ function loadViaWebpackNoCache<T>(webpackConfigPath: string, modulePath: string)
|
||||
const webpackConfig: webpack.Configuration = requireNewCopy(webpackConfigPath);
|
||||
webpackConfig.entry = modulePath;
|
||||
webpackConfig.target = 'node';
|
||||
webpackConfig.output = { path: '/', filename: 'webpack-output.js', libraryTarget: 'commonjs' };
|
||||
|
||||
// Make sure we preserve the 'path' and 'publicPath' config values if specified, as these
|
||||
// can affect the build output (e.g., when using 'file' loader, the publicPath value gets
|
||||
// set as a prefix on output paths).
|
||||
webpackConfig.output = webpackConfig.output || {};
|
||||
webpackConfig.output.path = webpackConfig.output.path || '/';
|
||||
webpackConfig.output.filename = 'webpack-output.js';
|
||||
webpackConfig.output.libraryTarget = 'commonjs';
|
||||
const outputVirtualPath = path.join(webpackConfig.output.path, webpackConfig.output.filename);
|
||||
|
||||
// In Node, we want anything under /node_modules/ to be loaded natively and not bundled into the output
|
||||
// (partly because it's faster, but also because otherwise there'd be different instances of modules
|
||||
@@ -85,7 +94,7 @@ function loadViaWebpackNoCache<T>(webpackConfigPath: string, modulePath: string)
|
||||
+ stats.toString({ chunks: false }));
|
||||
}
|
||||
|
||||
const fileContent = compiler.outputFileSystem.readFileSync('/webpack-output.js', 'utf8');
|
||||
const fileContent = compiler.outputFileSystem.readFileSync(outputVirtualPath, 'utf8');
|
||||
const moduleInstance = requireFromString<T>(fileContent);
|
||||
resolve(moduleInstance);
|
||||
} catch(ex) {
|
||||
|
||||
Reference in New Issue
Block a user