webpack.config.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import path from 'path';
  2. import webpack from 'webpack';
  3. // tslint:disable-next-line:no-var-requires
  4. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  5. const config: webpack.Configuration = {
  6. mode: 'production',
  7. entry: './assets/scripts/main.ts',
  8. output: {
  9. path: path.resolve(__dirname, 'static'),
  10. filename: 'main.js',
  11. },
  12. resolve: {
  13. extensions: ['.ts', '.js'],
  14. },
  15. module: {
  16. rules: [
  17. { test: /\.tsx?$/, loader: 'ts-loader' },
  18. {
  19. test: /\.scss$/,
  20. use: [
  21. {
  22. loader: MiniCssExtractPlugin.loader,
  23. },
  24. 'css-loader',
  25. 'sass-loader',
  26. ],
  27. },
  28. ],
  29. },
  30. plugins: [
  31. new MiniCssExtractPlugin({
  32. // Options similar to the same options in webpackOptions.output
  33. // both options are optional
  34. filename: '[name].css',
  35. chunkFilename: '[id].css',
  36. }),
  37. ],
  38. devtool: 'inline-source-map',
  39. };
  40. export default config;