Skip to content

Instantly share code, notes, and snippets.

@tlaitinen
Created May 22, 2018 11:54
Show Gist options
  • Select an option

  • Save tlaitinen/df537aee4b5c8b4f5fe4e4ad7fb2b28f to your computer and use it in GitHub Desktop.

Select an option

Save tlaitinen/df537aee4b5c8b4f5fe4e4ad7fb2b28f to your computer and use it in GitHub Desktop.
'use strict';
var path = require('path')
, webpack = require('webpack')
, HtmlWebpackPlugin = require('html-webpack-plugin');
var proxySettings = {
'/api/*': {
target: 'http://localhost:3000',
pathRewrite: {
'/api' : ''
}
}
};
module.exports = {
entry: "./index.tsx",
output: {
path: path.resolve('../../dist/frontend'),
filename: '[chunkhash].js',
publicPath: '/'
},
module: {
rules: [
{ test: /\.css$/, loader: "style-loader!css-loader" },
{
test: /\.less$/,
loader: "style-loader!css-loader!less-loader"
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.tsx?$/,
loader: [
'jsxgettext-loader?' + JSON.stringify({outputDir: '../../locale/templates/LC_MESSAGES', output: 'messages.pot'}),
'ts-loader'
],
exclude: /node_modules/
},
{
test: /\.jsx?$/,
use: [
'jsxgettext-loader?' + JSON.stringify({outputDir: '../../locale/templates/LC_MESSAGES', output: 'messages.pot'}),
'babel-loader'
],
exclude: /node_modules/
},
{
test: /\.scss$/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "sass-loader" // compiles Sass to CSS
}
]
},
{
test: /\.(png|gif|woff|woff2|eot|ttf|svg)($|\?v\=)/,
loader: 'url-loader?limi=100000',
exclude: /react-flags/
},
{
test: /\.jpg$/,
loaders: [
'file-loader?' + JSON.stringify({ hash: 'sha512', digest: 'hex', name: '[hash].[ext]' }),
'image-webpack-loader'
]
},
{
test: /\.po$/,
loader: 'json-loader!po-loader'
}
]
},
resolve: {
alias: {
'@src': '.',
'@backend': '../backend'
},
extensions: ['.ts', '.tsx', '.js', '.js', '.json'],
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': '"' + process.env.NODE_ENV + '"'
}
}),
new HtmlWebpackPlugin({
title: 'Title',
filename: 'index.html',
favicon: '../../resources/icons/favicon.ico'
}),
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /fi|en/)
],
devServer: {
historyApiFallback: {
index: '/'
},
proxy: proxySettings
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment