Simple approach for minifying blazor.*.js on release builds. Fixes #1003

Later we might want to emit both min and non-min variants of the file, when there is some way for developers to control which one they use
This commit is contained in:
Steve Sanderson 2018-07-06 16:23:44 +01:00
parent 5bccac05fc
commit 7bc67e1481
3 changed files with 7 additions and 5 deletions

View File

@ -26,7 +26,8 @@
<Target Name="RunWebpack" AfterTargets="ResolveReferences" Inputs="@(WebpackInputs)" Outputs="dist\blazor.webassembly.js" DependsOnTargets="EnsureNpmRestored">
<RemoveDir Directories="dist" />
<Exec Command="npm run build" />
<Exec Command="npm run build:debug" Condition="'$(Configuration)' == 'Debug'" />
<Exec Command="npm run build:production" Condition="'$(Configuration)' != 'Debug'" />
<ItemGroup>
<EmbeddedResource Include="dist\blazor.webassembly.js" LogicalName="blazor./blazor.webassembly.js" />
</ItemGroup>

View File

@ -4,7 +4,8 @@
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack --mode development",
"build:debug": "webpack --mode development",
"build:production": "webpack --mode production",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {

View File

@ -1,9 +1,9 @@
const path = require('path');
const webpack = require('webpack');
module.exports = {
module.exports = (env, args) => ({
resolve: { extensions: ['.ts', '.js'] },
devtool: 'inline-source-map',
devtool: args.mode === 'development' ? 'inline-source-map' : 'none',
module: {
rules: [{ test: /\.ts?$/, loader: 'ts-loader' }]
},
@ -11,4 +11,4 @@ module.exports = {
'blazor.webassembly': './src/Boot.WebAssembly.ts',
},
output: { path: path.join(__dirname, '/dist'), filename: '[name].js' }
};
});