From 03d31e81007dce502b5e34b9d1d887f260419c25 Mon Sep 17 00:00:00 2001 From: vios-fish Date: Tue, 2 Feb 2021 22:19:12 +0900 Subject: [PATCH] fix: fix webpack config --- front/webpack.common.js | 14 ++++---- front/webpack.dev.js | 72 ++++++++++++++++++++------------------- front/webpack.prod.js | 74 +++++++++++++++++++++-------------------- 3 files changed, 82 insertions(+), 78 deletions(-) diff --git a/front/webpack.common.js b/front/webpack.common.js index 5a0b72e6..65cedfad 100644 --- a/front/webpack.common.js +++ b/front/webpack.common.js @@ -1,5 +1,5 @@ -const path = require('path') -const JSX_PATH = __dirname + '/app'; +const path = require('path'); +const JSX_PATH = path.resolve(__dirname, '/app'); module.exports = { entry: { @@ -16,17 +16,17 @@ module.exports = { test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader', - query: { + options: { presets: ['react', 'stage-1'] } - }, + } ] }, resolve: { modules: ['node_modules'], extensions: ['.js', '.jsx'], alias: { - "automan": JSX_PATH, - }, + automan: JSX_PATH + } } -} +}; diff --git a/front/webpack.dev.js b/front/webpack.dev.js index d839dec3..9b5014af 100644 --- a/front/webpack.dev.js +++ b/front/webpack.dev.js @@ -1,37 +1,39 @@ -const webpack = require('webpack') -const merge = require('webpack-merge') -const common = require('./webpack.common.js') -const path = require('path') -const BundleTracker = require('webpack-bundle-tracker') -const CopyWebpackPlugin = require('copy-webpack-plugin') +const webpack = require('webpack'); +const merge = require('webpack-merge'); +const common = require('./webpack.common.js'); +const path = require('path'); +const BundleTracker = require('webpack-bundle-tracker'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); module.exports = merge(common, { - devtool: 'inline-source-map', - plugins: [ - new webpack.HotModuleReplacementPlugin(), - new BundleTracker({filename: 'webpack-stats.json'}), - new webpack.ProvidePlugin({ - $: 'jquery', - jQuery: 'jquery', - 'window.jQuery': 'jquery' - }), - new CopyWebpackPlugin([ - { - from: path.resolve(__dirname, 'static/img/'), - to: path.resolve(__dirname, 'dist/img/') - }, - { - from: path.resolve(__dirname, 'static/css/'), - to: path.resolve(__dirname, 'dist/css/') - }, - { - from: path.resolve(__dirname, 'static/js/'), - to: path.resolve(__dirname, 'dist/js/') - }, - { - from: path.resolve(__dirname, 'static/fonts/'), - to: path.resolve(__dirname, 'dist/fonts/') - }, - ]) - ] -}) + devtool: 'inline-source-map', + plugins: [ + new webpack.HotModuleReplacementPlugin(), + new BundleTracker({ filename: 'webpack-stats.json' }), + new webpack.ProvidePlugin({ + $: 'jquery', + jQuery: 'jquery', + 'window.jQuery': 'jquery' + }), + new CopyWebpackPlugin({ + patterns: [ + { + from: path.resolve(__dirname, 'static/img/'), + to: path.resolve(__dirname, 'dist/img/') + }, + { + from: path.resolve(__dirname, 'static/css/'), + to: path.resolve(__dirname, 'dist/css/') + }, + { + from: path.resolve(__dirname, 'static/js/'), + to: path.resolve(__dirname, 'dist/js/') + }, + { + from: path.resolve(__dirname, 'static/fonts/'), + to: path.resolve(__dirname, 'dist/fonts/') + } + ] + }) + ] +}); diff --git a/front/webpack.prod.js b/front/webpack.prod.js index 52e4af48..15fe5936 100644 --- a/front/webpack.prod.js +++ b/front/webpack.prod.js @@ -1,38 +1,40 @@ -const webpack = require('webpack') -const merge = require('webpack-merge') -const common = require('./webpack.common.js') -const path = require('path') -const BundleTracker = require('webpack-bundle-tracker') -const UglifyEsPlugin = require('uglify-es-webpack-plugin') -const CopyWebpackPlugin = require('copy-webpack-plugin') +const webpack = require('webpack'); +const merge = require('webpack-merge'); +const common = require('./webpack.common.js'); +const path = require('path'); +const BundleTracker = require('webpack-bundle-tracker'); +const UglifyEsPlugin = require('uglify-es-webpack-plugin'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); module.exports = merge(common, { - plugins: [ - new webpack.HotModuleReplacementPlugin(), - new BundleTracker({filename: 'webpack-stats.json'}), - new UglifyEsPlugin(), - new webpack.ProvidePlugin({ - $: 'jquery', - jQuery: 'jquery', - 'window.jQuery': 'jquery' - }), - new CopyWebpackPlugin([ - { - from: path.resolve(__dirname, 'static/img/'), - to: path.resolve(__dirname, 'dist/img/') - }, - { - from: path.resolve(__dirname, 'static/css/'), - to: path.resolve(__dirname, 'dist/css/') - }, - { - from: path.resolve(__dirname, 'static/js/'), - to: path.resolve(__dirname, 'dist/js/') - }, - { - from: path.resolve(__dirname, 'static/fonts/'), - to: path.resolve(__dirname, 'dist/fonts/') - }, - ]) - ], -}) + plugins: [ + new webpack.HotModuleReplacementPlugin(), + new BundleTracker({ filename: 'webpack-stats.json' }), + new UglifyEsPlugin(), + new webpack.ProvidePlugin({ + $: 'jquery', + jQuery: 'jquery', + 'window.jQuery': 'jquery' + }), + new CopyWebpackPlugin({ + patterns: [ + { + from: path.resolve(__dirname, 'static/img/'), + to: path.resolve(__dirname, 'dist/img/') + }, + { + from: path.resolve(__dirname, 'static/css/'), + to: path.resolve(__dirname, 'dist/css/') + }, + { + from: path.resolve(__dirname, 'static/js/'), + to: path.resolve(__dirname, 'dist/js/') + }, + { + from: path.resolve(__dirname, 'static/fonts/'), + to: path.resolve(__dirname, 'dist/fonts/') + } + ] + }) + ] +});