123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- const path = require('path');
- const webpack = require('webpack');
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- const autoprefixer = require('autoprefixer');
- const Dotenv = require('dotenv-webpack');
- const commonCSSLoaderOptions = {
- importLoaders: 2,
- url: false
- };
- const cssLoaderOptions = {
- ...commonCSSLoaderOptions,
- modules: false
- };
- const scssLoaderOptions = {
- ...commonCSSLoaderOptions,
- modules: true,
- localIdentName: '[name]_[local]--[hash:base64:5]'
- };
- const postCSSLoaderOptions = {
- ident: 'postcss',
- plugins: () => [autoprefixer(),],
- };
- module.exports = {
- //core-js/features/object: ie 대응
- entry: ['core-js/features/object', './src/index.tsx', './assets/css/common.css'],
- output: {
- filename: 'bundle.[hash].js',
- publicPath: '/'
- },
- resolve: {
- alias: {
- '@src': path.resolve('./src'),
- '@assets': path.resolve('./assets'),
- },
- extensions: ['.ts', '.tsx', '.js', '.jsx', '.json', 'scss']
- },
- node: {
- fs: 'empty'
- },
- module: {
- rules: [
- {
- test: /\.(js|jsx|ts|tsx)$/,
- exclude: /node_modules/,
- use: [{
- loader: 'babel-loader',
- options: {
- presets: [
- '@babel/preset-env',
- '@babel/preset-react',
- '@babel/preset-typescript',
- ],
- }
- }],
- },
- {
- test: /\.(css)$/,
- use: [
- { loader: 'style-loader' },
- { loader: 'css-loader', options: cssLoaderOptions },
- ],
- },
- {
- test: /\.(scss)$/,
- use: [
- { loader: 'style-loader' },
- { loader: 'css-loader', options: scssLoaderOptions },
- { loader: 'postcss-loader', options: postCSSLoaderOptions },
- { loader: 'sass-loader' },
- ],
- },
- {
- test: /\.svg$/,
- use: [{
- loader: '@svgr/webpack',
- options: {
- svgoConfig: {
- plugins: {
- removeViewBox: false
- }
- }
- }
- }, 'url-loader'],
- },
- ]
- },
- plugins: [
- new HtmlWebpackPlugin({
- template: './public/index.html',
- }),
- new webpack.HotModuleReplacementPlugin(),
- new Dotenv(),
- new webpack.DefinePlugin({
- 'process.env': JSON.stringify(process.env)
- })
- ],
- };
|