Browse Source

Build fixes

pull/1/head
Sebastian 10 years ago
parent
commit
ba96902329
  1. 19
      src/Squidex/Startup.cs
  2. 15
      src/Squidex/app-config/webpack.config.js
  3. 2
      src/Squidex/app-config/webpack.run.dev.js
  4. 24
      src/Squidex/app-config/webpack.run.prod.js
  5. 17
      src/Squidex/app-config/webpack.test.coverage.js
  6. 2
      src/Squidex/app/app.component.html
  7. 2
      src/Squidex/app/components/public/home-page.component.html
  8. 0
      src/Squidex/app/images/loader.gif
  9. 0
      src/Squidex/app/images/logo.png
  10. 1
      src/Squidex/package.json
  11. 2
      src/Squidex/wwwroot/index.html
  12. BIN
      src/Squidex/wwwroot/loader.gif

19
src/Squidex/Startup.cs

@ -8,6 +8,7 @@
using System;
using System.IO;
using System.Linq;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Builder;
@ -16,14 +17,14 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Net.Http.Headers;
using Squidex.Configurations;
using Squidex.Configurations.Domain;
using Squidex.Configurations.EventStore;
using Squidex.Configurations.Identity;
using Squidex.Configurations.Web;
using Squidex.Store.MongoDb;
using System.Linq;
using Squidex.Pipeline;
using Squidex.Store.MongoDb;
// ReSharper disable ConvertClosureToMethodGroup
// ReSharper disable AccessToModifiedClosure
@ -175,7 +176,19 @@ namespace Squidex
});
}
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions
{
OnPrepareResponse = (context) =>
{
var headers = context.Context.Response.GetTypedHeaders();
headers.CacheControl = new CacheControlHeaderValue
{
MaxAge = TimeSpan.FromDays(60),
};
}
});
}
private static bool IsIdentityRequest(HttpContext context)

15
src/Squidex/app-config/webpack.config.js

@ -50,7 +50,10 @@ module.exports = {
test: /\.html$/,
loader: 'html'
}, {
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)(\?.*$|$)/,
test: /\.(woff|woff2|ttf|eot)(\?.*$|$)/,
loader: 'file?name=assets/[name].[hash].[ext]'
}, {
test: /\.(png|jpe?g|gif|svg|ico)(\?.*$|$)/,
loader: 'file?name=assets/[name].[hash].[ext]'
}, {
test: /\.css$/,
@ -72,12 +75,20 @@ module.exports = {
*
* See: https://github.com/wbuchwalter/tslint-loader
*/
emitErrors: false,
emitErrors: true,
/**
* Share the configuration file with the IDE
*/
configuration: require('./../tslint.json')
},
htmlLoader: {
/**
* Define the root for images, so that we can use absolute urls
*
* See: https://github.com/webpack/html-loader#Advanced_Options
*/
root: helpers.root('app', 'images')
},
sassLoader: {
includePaths: [helpers.root('app', 'theme')]
},

2
src/Squidex/app-config/webpack.run.dev.js

@ -15,6 +15,8 @@ module.exports = webpackMerge(runConfig, {
*/
devtool: 'cheap-module-eval-source-map',
//debug: true,
output: {
filename: '[name].js',
// Set the public path, because we are running the website from another port (5000)

24
src/Squidex/app-config/webpack.run.prod.js

@ -6,9 +6,7 @@ ExtractTextPlugin = require('extract-text-webpack-plugin'),
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
runConfig.plugins[0].options.options.tslint.emitErrors = true;
module.exports = webpackMerge(runConfig, {
module.exports = webpackMerge.smart(runConfig, {
devtool: 'source-map',
output: {
@ -57,6 +55,9 @@ module.exports = webpackMerge(runConfig, {
test: /\.scss$/,
include: helpers.root('app', 'theme'),
loader: ExtractTextPlugin.extract({ fallbackLoader: 'style', loader: 'css!sass?sourceMap' })
}, {
test: /\.(png|jpe?g|gif|svg|ico)(\?.*$|$)/,
loaders: ['file?hash=sha512&digest=hex&name=[hash].[ext]', 'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false']
}
]
},
@ -65,20 +66,17 @@ module.exports = webpackMerge(runConfig, {
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({ 'process.env': { 'ENV': JSON.stringify(ENV) } }),
/*
* Puts each bundle into a file and appends the hash of the file to the path.
*
* See: https://github.com/webpack/extract-text-webpack-plugin
*/
new ExtractTextPlugin('[name].[hash].css'),
new webpack.optimize.UglifyJsPlugin({
mangle: {
screw_ie8: true, keep_fnames: true
}
}),
function () {
this.plugin('done', function (stats) {
if (stats.compilation.errors && stats.compilation.errors.length && process.argv.indexOf('--watch') == -1) {
console.log(stats.compilation.errors);
throw new Error('webpack build failed.');
}
});
}
]
});

17
src/Squidex/app-config/webpack.test.coverage.js

@ -4,7 +4,7 @@ var webpackMerge = require('webpack-merge'),
helpers = require('./helpers'),
testConfig = require('./webpack.test.js');
testConfig.module.loaders.shift();
removeTsLoader();
module.exports = webpackMerge(testConfig, {
module: {
@ -23,4 +23,17 @@ module.exports = webpackMerge(testConfig, {
}
});
console.log(JSON.stringify(module.exports, null, 4));
function removeTsLoader() {
var tsModuleIndex = -1;
for (var i = 0, len = testConfig.module.loaders.length; i < len; i += 1) {
if (testConfig.module.loaders[i].test.source.indexOf('.ts') > 0) {
tsModuleIndex = i;
break;
}
}
if (tsModuleIndex >= 0) {
testConfig.module.loaders.splice(tsModuleIndex, 1);
}
}

2
src/Squidex/app/app.component.html

@ -1,7 +1,7 @@
<main>
<router-outlet (activate)="isLoaded = true">
<div class="loading" *ngIf="!isLoaded">
<img src="/images/loader.gif" />
<img src="/loader.gif" />
<div>Loading awesomeness</div>
</div>

2
src/Squidex/app/components/public/home-page.component.html

@ -1,5 +1,5 @@
<div class="content">
<img class="logo" src="/images/logo.png" />
<img class="logo" src="/logo.png" />
<button class="btn btn-primary btn-lg login-button" (click)="login()">Login to Squidex</button>

0
src/Squidex/wwwroot/images/loader.gif → src/Squidex/app/images/loader.gif

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

0
src/Squidex/wwwroot/images/logo.png → src/Squidex/app/images/logo.png

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

1
src/Squidex/package.json

@ -49,6 +49,7 @@
"font-awesome-sass-loader": "^1.0.1",
"html-loader": "^0.4.3",
"html-webpack-plugin": "^2.22.0",
"image-webpack-loader": "^3.0.0",
"istanbul-instrumenter-loader": "^0.2.0",
"jasmine-core": "^2.4.1",
"karma": "^1.1.1",

2
src/Squidex/wwwroot/index.html

@ -36,7 +36,7 @@
<body>
<sqx-app>
<div class="loading">
<img src="/images/loader.gif" />
<img src="/loader.gif" />
<div>Loading awesomeness</div>
</div>

BIN
src/Squidex/wwwroot/loader.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Loading…
Cancel
Save