Giter VIP home page Giter VIP logo

aureliadotnettemplatematerialize's People

Contributors

elmt1 avatar gerfen avatar maximbalaganskiy avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

paul-moura gerfen

aureliadotnettemplatematerialize's Issues

Minimizing CSS Selectors for production

Hi,

I have been using you template for a while and now I'm trying to do a production build with minimized css selectors.

So I want my .long-class-name-for-element to become .ytxCvs and #this-id-selector-that-is-also-very-long to become #d34das etc.

Can you help me with the webpack configuration for it? I tried searching online for answers but samples of webpack configurations are quite confusing. Here is my current webpack.config.js:

const path = require("path");
const webpack = require("webpack");
const { AureliaPlugin, ModuleDependenciesPlugin, GlobDependenciesPlugin } = require("aurelia-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");

const bundleOutputDir = "./wwwroot/dist";

module.exports = (env, argv) => {
	if ((!argv || !argv.mode) && process.env.ASPNETCORE_ENVIRONMENT === "Development") {
		argv = { mode: "development" };
	}
	console.log("mode =", argv.mode);
	const isDevBuild = argv.mode !== "production";
	const cssLoaders = isDevBuild ? ["css-loader"] : ["css-loader", "postcss-loader"];
	const scssLoaders = [...cssLoaders, "sass-loader"];
	return [{
		target: "web",
		mode: isDevBuild ? "development" : "production",
		entry: { "app": ["es6-promise/auto", "aurelia-bootstrapper"] },
		resolve: {
			extensions: [".ts", ".js"],
			modules: ["ClientApp", "node_modules"]
		},
		output: {
			path: path.resolve(bundleOutputDir),
			publicPath: "/dist/",
			filename: "[name].js",
			chunkFilename: "[name].js"
		},
		module: {
			rules: [
				{ test: /\.(woff|woff2)(\?|$)/, loader: "url-loader?limit=1" },
				{ test: /\.(png|eot|ttf|svg)(\?|$)/, loader: "url-loader?limit=100000" },
				{ test: /\.ts$/i, include: [/ClientApp/, /node_modules/], use: "awesome-typescript-loader" },
				{ test: /\.html$/i, use: "html-loader" },
				{ test: /\.css$/i, include: [/node_modules/], issuer: /\.html$/i, use: cssLoaders },
				{ test: /\.css$/i, include: [/node_modules/], exclude: [/\materialize.css$/], issuer: [{ not: [{ test: /\.html$/i }] }], use: ["style-loader", ...cssLoaders] },
				{ test: /\materialize.css$/, use: [{ loader: MiniCssExtractPlugin.loader }, ...cssLoaders] },
				{ test: /\.scss$/i, issuer: /(\.html|empty-entry\.js)$/i, use: scssLoaders },
				{ test: /\.scss$/i, issuer: /\.ts$/i, use: ["style-loader", ...scssLoaders] }
			]
		},
		optimization: {
			splitChunks: {
				chunks: "all"
				// uncomment the following to create a separate bundle for each npm module
				//maxInitialRequests: Infinity,
				//minSize: 0,
				//cacheGroups: {
				//	vendor: {
				//		test: /[\\/]node_modules[\\/]/,
				//		name(module) {
				//			//get the name. E.g. node_modules/packageName/not/this/part.js
				//			//or node_modules/packageName
				//			const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];

				//			//npm package names are URL-safe, but some servers don't like @ symbols
				//			return `npm.${packageName.replace('@', '')}`;
				//		}
				//	}
				//}
			},
			minimizer: [
				new TerserPlugin({
					cache: true,
					parallel: true,
					sourceMap: true // set to true if you want JS source maps
				}),
			].concat(isDevBuild ? [] : [new OptimizeCSSAssetsPlugin({})])
		},
		devtool: isDevBuild ? "source-map" : false,
		performance: {
			hints: false
		},
		plugins: [
			new webpack.DefinePlugin({ IS_DEV_BUILD: JSON.stringify(isDevBuild) }),
            new HtmlWebpackPlugin({ template: 'Pages/Shared/_ClientLayoutTemplate.cshtml', filename: "../../Pages/Shared/_ClientLayout.cshtml", inject: false, metadata: {}, alwaysWriteToDisk: true }),
			new AureliaPlugin({ aureliaApp: "main" }),
			new GlobDependenciesPlugin({ "main": ["ClientApp/**/*.{ts,html}"] }),
            new ModuleDependenciesPlugin({
                "aurelia-chart": ['./elements/chart-element', './attributes/chart-attribute']
            }),
			new MiniCssExtractPlugin()
		]
	}];
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.