Skip to content

Instantly share code, notes, and snippets.

View hach-que's full-sized avatar

June Rhodes hach-que

View GitHub Profile
// Instructs WebPack to bundle up skin assets alongside TinyMCE. See:
// https://www.tinymce.com/docs/advanced/usage-with-module-loaders/#webpackfile-loader
(require as any).context(
'file-loader?name=[path][name].[ext]&outputPath=assets/&context=node_modules/tinymce!tinymce/skins',
true,
/.*/
);
<!-- ... -->
<ItemGroup>
<WebpackInputs Include="app\**\*" />
<WebpackInputs Include="webpack.config.ts" />
</ItemGroup>
<ItemGroup>
<WebpackOutputs Include="wwwroot\assets\**\*" />
<WebpackOutputs Include="wwwroot\css\**\*" />
<WebpackOutputs Include="wwwroot\js\**\*" />
</ItemGroup>
@hach-que
hach-que / _ScriptsTemplate.cshtml
Last active December 15, 2017 05:51
_ScriptsTemplate.cshtml
<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
<script src="<%= htmlWebpackPlugin.files.chunks[chunk].entry %>"></script>
<% } %>
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Rendering;
using Newtonsoft.Json;
using System;
using System.Threading.Tasks;
namespace Webpack
{
public static class WebpackHtmlHelperExtensions
{
@using Webpack
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
@await Html.WebpackStylesAsync("page-common")
@RenderSection("styles", required: false)
</head>
<script src="/js/polyfills.f501bf962ba966ac6403.min.js"></script>
<script src="/js/jquery.e884b239c22e79ed9c69.min.js"></script>
<script src="/js/bootstrap.bceff9462fe562e8d30e.min.js"></script>
<script src="/js/page-common.e3d4ffd6e23be8f5005c.min.js"></script>
<script src="/js/font-awesome.576c74921ff4f74c0048.min.js"></script>
plugins: [
// >> Here we're matching bundles that start with "page-" <<
...bundles.filter(x => x.startsWith("page-")).map((value) => {
return new HtmlWebpackPlugin({
filename: path.join(__dirname, '/Views/Shared/Assets/_Gen_' + value + '_Scripts.cshtml'),
template: path.join(__dirname, '/Views/Shared/Assets/_ScriptsTemplate.cshtml'),
// >> Configures the chunks for global "page-" bundles <<
chunks: ['polyfills', 'jquery', 'bootstrap', value, 'font-awesome'],
/// <reference path="../../../node_modules/@types/jquery/index.d.ts" />
interface PageData {
message: string;
}
$(function() {
let data = JSON.parse($("#page-data").text()) as PageData;
alert(data.message);
});
@using Webpack
@section scripts {
@await Html.WebpackScriptsAsync("my-behaviour")
}
@section styles {
@await Html.WebpackStylesAsync("my-behaviour")
}
<p>This is my page!</p>
saveId attempts deaths deathPercentage
Dimension Jump 8: Break 3609 3244 89.89
Dimension Jump 10: Hop Hop Hop 2680 2368 88.36
Gravity 6: Skyfire 2325 2138 91.96
perfect_03 1200 1190 99.17
Gravity 9: Gravity Jam 1269 1145 90.23
Tutorial 9: Tempramental 1660 1087 65.48
Gravity 8: Grid 1168 1013 86.73
Gravity 7: Hopscotch 1134 956 84.3
Tutorial 6: Do Not Touch 1361 738 54.22