-
-
-

+
+
+

Loom Forge

diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..6d0fe5f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "outDir": "./public/assets/js", + "noImplicitAny": true, + "module": "commonjs", + "target": "es6", + "allowJs": true, + "moduleResolution": "node", + "esModuleInterop": true, + "skipLibCheck": true + }, + "include": ["./src/js/loom.ts"] +} \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..9600fb0 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,77 @@ +const path = require('path'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin'); +const TerserPlugin = require('terser-webpack-plugin'); +const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); + +const entries = { + loomScripts: './src/js/loom.ts', + loomStyles: './src/scss/loom.scss', +} +const ignoreFiles = Object.keys(entries).reduce((acc, key) => { + if (entries[key].endsWith('.scss')) { + acc.push(`${key}.js`); + } + + return acc; +}, []); + +module.exports = (env, options) => { + const isProduction = options.mode === 'production'; + + return { + entry: entries, + module: { + rules: [ + { + test: /\.ts?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /\.s[ac]ss$/i, + use: [ + MiniCssExtractPlugin.loader, + 'css-loader', + { + loader: 'postcss-loader', + options: { + postcssOptions: { + plugins: [ + require('autoprefixer') + ] + } + } + }, + 'sass-loader' + ], + exclude: /node_modules/ + }, + ], + }, + plugins: [ + new MiniCssExtractPlugin({ + filename: 'css/[name].css', + }), + new IgnoreEmitPlugin(ignoreFiles) + ], + optimization: isProduction ? { + minimize: true, + minimizer: [ + new TerserPlugin(), + new CssMinimizerPlugin(), + ] + } : {}, + resolve: { + extensions: ['.ts', '.js', '.css', '.scss'] + }, + watchOptions: { + poll: true, + ignored: /node_modules/ + }, + output: { + filename: 'js/[name].js', + path: path.resolve(__dirname, 'public/assets/') + } + }; +} \ No newline at end of file