Created
July 23, 2020 20:31
-
-
Save AZagatti/0ffb87bc4679aacffc8c13f6664f662e to your computer and use it in GitHub Desktop.
Webpack config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config(); | |
const Dotenv = require('dotenv-webpack'); | |
import * as webpack from 'webpack'; | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); | |
const htmlPlugin = new HtmlWebpackPlugin({ | |
template: './public/index.html', | |
}); | |
const config = { | |
mode: 'development', | |
entry: './index.tsx', | |
resolve: { | |
extensions: ['.ts', '.tsx', '.js', '.json'], | |
plugins: [new TsconfigPathsPlugin({ configFile: './tsconfig.json' })], | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.tsx?$/, | |
exclude: /node_modules/, | |
loader: 'awesome-typescript-loader', | |
}, | |
{ | |
test: /\.css/, | |
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }], | |
}, | |
{ | |
test: /.*\.(gif|png|jpe?g)$/i, | |
use: { | |
loader: 'file-loader', | |
}, | |
}, | |
], | |
}, | |
devServer: { | |
historyApiFallback: true, | |
}, | |
plugins: [htmlPlugin, new Dotenv()], | |
}; | |
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config(); | |
const Dotenv = require('dotenv-webpack'); | |
const path = require('path'); | |
import * as webpack from 'webpack'; | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); | |
const htmlPlugin = new HtmlWebpackPlugin({ | |
template: './public/index.html', | |
filename: './index.html', | |
}); | |
const config: webpack.Configuration = { | |
mode: 'production', | |
entry: './index.tsx', | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
filename: 'bundle.js', | |
}, | |
resolve: { | |
extensions: ['.ts', '.tsx', '.js', '.json'], | |
plugins: [new TsconfigPathsPlugin({ configFile: './tsconfig.json' })], | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.tsx?$/, | |
exclude: /node_modules/, | |
loader: 'awesome-typescript-loader', | |
}, | |
{ | |
test: /\.css/, | |
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }], | |
}, | |
{ | |
test: /.*\.(gif|png|jpe?g)$/i, | |
use: { | |
loader: 'file-loader', | |
}, | |
}, | |
], | |
}, | |
plugins: [htmlPlugin, new Dotenv()], | |
}; | |
module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment