123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- /* eslint-disable */
- // Common Config is used in Development and Production Mode.
- const path = require('path');
- const CleanWebpackPlugin = require('clean-webpack-plugin');
- const webpack = require('webpack');
- const HtmlWebPackPlugin = require('html-webpack-plugin');
- const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
- const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
- const StylelintPlugin = require('stylelint-webpack-plugin');
- const ESLintPlugin = require('eslint-webpack-plugin');
- const SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
- // Linting
- const TSLintPlugin = require('tslint-webpack-plugin');
- const ImageminPlugin = require('imagemin-webpack-plugin').default;
- const imageminMozjpeg = require('imagemin-mozjpeg');
- module.exports = {
- entry: {
- index: './src/index.ts'
- },
- output: {
- path: path.resolve(__dirname, 'dist'),
- filename: './js/[name].[hash:6].bundle.js'
- },
- module: {
- rules: [
- // Raw Loader
- {
- test: /\.txt$/,
- use: 'raw-loader'
- },
- // HTML Loader
- {
- test: /\.html$/,
- use: [
- {
- loader: 'html-loader',
- options: {minimize: true}
- }
- ]
- },
- // CSS/SCSS Loader & Minimizer
- {
- test: /\.(sa|sc|c)ss$/,
- use: [
- "style-loader",
- "css-loader",
- {
- loader: 'postcss-loader',
- options: {
- postcssOptions: {
- parser: "sugarss",
- },
- },
- },
- {
- loader: 'resolve-url-loader',
- options: {}
- },
- {
- loader: 'sass-loader',
- options: {
- sourceMap: true,
- sourceMapContents: false
- }
- }
- ],
-
- },
- {
- test: /\.svg$/,
- use: [
- {
- loader: 'svg-sprite-loader',
- options: {
- extract: true,
- } },
- 'svg-transform-loader',
- {
- loader: 'svgo-loader',
- options: {
- plugins: [
- {removeTitle: true},
- {convertColors: {shorthex: false}},
- {convertPathData: false},
- {convertPathData:true}
- ]
- }
- }
- ]
- },
- // Image Loader
- {
- test: /\.(png|jpeg|jpg|webp|gif|ico)/i,
- use: [
- {
- loader: 'url-loader',
- options: {
- // publicPath: '../',
- //name: './assets/images/' + '[name].[ext]',
- limit: 10000,
- //limit:false,
- //publicPath: '../'
- }
- },
- ]
- },
- // Babel Loader
- {
- test: /\.ts(x?)$/,
- exclude: /node_modules/,
- loader: 'babel-loader'
- },
- {
- test: /\.m?js$/,
- exclude: /(node_modules|bower_components)/,
- use: {
- loader: 'babel-loader',
- options: {
- presets: ['@babel/preset-env'],
- plugins: [
- '@babel/plugin-proposal-object-rest-spread',
- '@babel/plugin-proposal-nullish-coalescing-operator',
- '@babel/plugin-proposal-optional-chaining',
- '@babel/plugin-proposal-class-properties'
- ]
- }
- },
- },
- // XML Loader
- {
- test: /\.xml$/,
- use: [
- 'xml-loader'
- ]
- },
- {
- test: require.resolve("bootstrap"),
- loader: "expose-loader",
- options: {
- exposes: ["bootstrap"],
- },
- },
- {
- test: require.resolve("jquery"),
- loader: "expose-loader",
- options: {
- exposes: ["$", "jQuery"],
- },
- },
- {
- test: require.resolve("underscore"),
- loader: "expose-loader",
- options: {
- exposes: [
- "_.map|map",
- {
- globalName: "_.reduce",
- moduleLocalName: "reduce",
- },
- {
- globalName: ["_", "filter"],
- moduleLocalName: "filter",
- },
- ],
- },
- },
-
- ]
- },
- resolve: {
- extensions: ['.js', '.jsx', '.tsx', '.ts', '.json'],
- alias: {
- riSvg: 'remixicon/icons/'
- }
- },
- plugins: [
- new CleanWebpackPlugin(),
- new ImageminPlugin({
- test: /\.(jpe?g|png|gif|svg)$/i,
- // lossLess gif compressor
- gifsicle: {
- optimizationLevel: 9
- },
- // lossy png compressor, remove for default lossLess
- pngquant: ({
- quality: '75'
- }),
- // lossy jpg compressor
- plugins: [imageminMozjpeg({
- quality: '75'
- })],
- destination: './webpack',
- }),
- new ESLintPlugin({
- cache: true,
- ignore: true,
- useEslintrc: true,
- }),
- new HtmlWebPackPlugin({
- title: 'SqueezeESP32',
- template: './src/index.ejs',
- filename: 'index.html',
- inject: 'body',
- minify: {
- html5 : true,
- collapseWhitespace : true,
- minifyCSS : true,
- minifyJS : true,
- minifyURLs : false,
- removeAttributeQuotes : true,
- removeComments : true, // false for Vue SSR to find app placeholder
- removeEmptyAttributes : true,
- removeOptionalTags : true,
- removeRedundantAttributes : true,
- removeScriptTypeAttributes : true,
- removeStyleLinkTypeAttributese : true,
- useShortDoctype : true
- },
- favicon: "./src/assets/images/favicon-32x32.png",
-
- excludeChunks: ['test'],
- }),
-
- new ScriptExtHtmlWebpackPlugin({
- defaultAttribute: 'defer'
- }),
- // // Load Lodash Features Separately https://www.npmjs.com/package/lodash-webpack-plugin
- new LodashModuleReplacementPlugin({
- 'collections': true,
- 'paths': true,
- }),
- new TSLintPlugin({
- files: ['./src/ts/*.ts']
- }),
- new StylelintPlugin( {
- files: ['./src/sass/*.s?(a|c)ss'],
- configFile: './config/.stylelintrc',
- emitError: true,
- emitWarning: true,
- failOnError: false,
- fix: true
- }),
- new SpriteLoaderPlugin({plainSprite: true})
- ],
- };
|