1
0
mirror of https://github.com/byulmaru/quesdon synced 2024-11-23 14:36:02 +09:00
quesdon/webpack.config.js
2019-11-11 21:30:26 +11:00

53 lines
1.5 KiB
JavaScript

const webpack = require("webpack")
const UglifyJSPlugin = require("uglifyjs-webpack-plugin")
const isProduction = process.env.NODE_ENV == "production"
module.exports = {
mode: isProduction ? "production": "development",
entry: "./src/client/index.ts",
output: {
path: __dirname+"/dist/client",
filename: "bundle.js",
publicPath: "/assets/",
},
devServer: {
contentBase: "dist/client",
proxy: {
"/": "http://localhost:"+(process.env.BACK_PORT || 3000)
},
},
plugins: [
new webpack.ProvidePlugin({
"$": "jquery",
apiFetch: __dirname+"/src/client/api-fetch.ts"
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
],
module: {
rules: [
{test: /\.css$/, loader: 'style-loader!css-loader'},
{test: /\.(woff2?|ttf|eot|svg)$/, loader: 'file-loader'},
{test: /\.tsx?$/, loader: isProduction ? 'babel-loader!ts-loader' : 'ts-loader'},
]
},
resolve: {
extensions: [".ts", ".tsx", ".js"]
},
optimization: {
minimizer: isProduction ? [
new UglifyJSPlugin({
uglifyOptions: {
keep_classnames: true
}
})
]: []
}
}
// if (process.env.NODE_ENV == "production") {
// module.exports.plugins.push(new UglifyJsPlugin({
// }))
// }