Skip to content

Commit

Permalink
chore: ts-loader를 이용하기 위한 webpack.local.js 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hwangstar156 committed Oct 23, 2022
1 parent aa7ebcf commit e35e033
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 6 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"ts-jest": "^28.0.7"
},
"scripts": {
"start": "webpack serve --open --config webpack/webpack.dev.js",
"start": "webpack serve --open --config webpack/webpack.local.js",
"build": "webpack --mode=production --config webpack/webpack.prod.js",
"build-dev": "webpack --mode=production --config webpack/webpack.dev.js",
"storybook": "start-storybook -p 6006",
Expand Down
14 changes: 9 additions & 5 deletions frontend/webpack/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ dotenv.config({
});

module.exports = merge(common, {
mode: 'development',
devtool: 'eval-cheap-module-source-map',
mode: 'production',
devtool: false,
cache: {
type: 'filesystem',
},
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
cacheCompression: false,
cacheDirectory: true,
},
},
],
},
Expand All @@ -25,7 +32,4 @@ module.exports = merge(common, {
'process.env': JSON.stringify(process.env),
}),
],
optimization: {
minimize: true,
},
});
36 changes: 36 additions & 0 deletions frontend/webpack/webpack.local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common');
const path = require('path');
const webpack = require('webpack');
const dotenv = require('dotenv');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

dotenv.config({
path: path.join(__dirname, './.env.development'),
});

module.exports = merge(common, {
mode: 'development',
devtool: 'eval-cheap-module-source-map',
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)?$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
transpileOnly: true,
},
},
],
},
plugins: [
new ForkTsCheckerWebpackPlugin(),
new webpack.DefinePlugin({
'process.env': JSON.stringify(process.env),
}),
],
optimization: {
minimize: true,
},
});
7 changes: 7 additions & 0 deletions frontend/webpack/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@ dotenv.config({

module.exports = merge(common, {
mode: 'production',
cache: {
type: 'filesystem',
},
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
cacheCompression: false,
cacheDirectory: true,
},
},
],
},
Expand Down

0 comments on commit e35e033

Please sign in to comment.