1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- 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'
- },]
- },
- {
- 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)
- })
- ],
- };
|