Skip to content

Commit

Permalink
Update packages and build configs
Browse files Browse the repository at this point in the history
  • Loading branch information
vrimar committed Oct 19, 2021
1 parent 8857cc3 commit 481885e
Show file tree
Hide file tree
Showing 9 changed files with 1,448 additions and 6,227 deletions.
3 changes: 2 additions & 1 deletion docs/src/index.template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

<body>
<div id="Docs"></div>
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=default,Array.prototype.includes,Array.prototype.find,Array.prototype.findIndex"></script>
<script
src="https://cdn.polyfill.io/v3/polyfill.js?features=default,Array.prototype.includes,Array.prototype.find,Array.prototype.findIndex"></script>
</body>

</html>
2 changes: 1 addition & 1 deletion docs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const DEFAULT_ROOT = '/introduction/getting-started';

m.route.prefix = '#';

const resolveRoute = (wrapper: m.Component) => ({
const resolveRoute = (wrapper: m.Component<IDocumentationData>) => ({
onmatch(attrs, requestedPath) {
attrs.docs = docs;
attrs.requestedPath = requestedPath;
Expand Down
3 changes: 1 addition & 2 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": "../",
"declaration": false,
"outDir": "./dist",
"module": "commonjs",
"resolveJsonModule": true
},
"include": [
"./src",
Expand Down
59 changes: 31 additions & 28 deletions docs/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const path = require('path');
const webpack = require('webpack');
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 { CheckerPlugin } = require('awesome-typescript-loader');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const HTMLPlugin = require('html-webpack-plugin');
const packageJson = require('../package.json');

const APP_TITLE = `Construct-ui: ${packageJson.description} - v${packageJson.version}`;
Expand All @@ -14,24 +12,31 @@ const PORT = 9000;

const plugins = {
common: [
new HtmlWebpackPlugin({
new HTMLPlugin({
title: APP_TITLE,
template: TEMPLATE_PATH
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(isProduction ? "production" : "development"),
'process.env.NODE_DEBUG': JSON.stringify(isProduction ? "production" : "development"),
VERSION: JSON.stringify(packageJson.version),
})
],
production: [
new MiniCssExtractPlugin({
filename: "[name].[hash].css",
chunkFilename: "[id].[hash].css"
filename: "[name].[fullhash].css",
chunkFilename: "[id].[fullhash].css"
}),
new OptimizeCSSAssetsPlugin(),
new TerserPlugin()
],
development: [
new CheckerPlugin(),
new ForkTsCheckerWebpackPlugin({
typescript: {
diagnosticOptions: {
semantic: true,
syntactic: true,
},
},
})
]
}

Expand All @@ -58,17 +63,23 @@ const cssLoader = {
'style-loader',
'css-loader',
'resolve-url-loader',
'sass-loader?sourceMap'
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
}

/** @type {import('webpack').Configuration} */
module.exports = {
mode: isProduction ? 'production' : 'development',
entry: {
app: './src/index.ts'
},
output: {
filename: isProduction ? 'app-[hash].js' : 'app.js',
filename: isProduction ? 'app-[fullhash].js' : 'app.js',
path: path.resolve(__dirname, 'public')
},
module: {
Expand All @@ -89,36 +100,28 @@ module.exports = {
{
test: /\.ts?$/,
exclude: /node_modules/,
use: {
loader: 'awesome-typescript-loader',
options: {
useCache: true,
forceIsolatedModules: true
}
loader: 'ts-loader',
options: {
transpileOnly: true
}
}
]
},
plugins: plugins.common.concat(isProduction ? plugins.production : plugins.development),
devtool: isProduction ? undefined : 'cheap-eval-source-map',
devtool: isProduction ? 'source-map' : 'eval-cheap-source-map',
resolve: {
extensions: ['.ts', '.js'],
alias: {
'@shared': path.resolve(__dirname, '../src/_shared'),
'@': path.resolve(__dirname, '../src')
}
},
optimization: isProduction ? {} : {
removeAvailableModules: false,
removeEmptyChunks: false,
splitChunks: false
},
stats: isProduction ? undefined : "minimal",
devServer: {
port: PORT,
stats: 'errors-only',
open: true,
watchOptions: {
ignored: /node_modules/
}
},
watchOptions: {
ignored: '**/node_modules'
}
}
Loading

0 comments on commit 481885e

Please sign in to comment.