2019-01-27 20:29:33 +00:00
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
|
|
const Visualizer = require('webpack-visualizer-plugin');
|
|
|
|
const path = require("path");
|
2019-03-05 02:48:31 +00:00
|
|
|
const fs = require("fs");
|
|
|
|
const config = require("./config.json");
|
|
|
|
const url = require("url");
|
2019-01-27 20:29:33 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
devServer: {
|
|
|
|
host: "0.0.0.0", // Defaults to `localhost`
|
|
|
|
open: false, // Open the page in browser,
|
|
|
|
contentBase: path.join(__dirname, 'dist'),
|
2019-03-05 02:48:31 +00:00
|
|
|
disableHostCheck: true,
|
|
|
|
headers: {
|
|
|
|
"Access-Control-Allow-Origin": "*"
|
|
|
|
},
|
|
|
|
watchOptions: {
|
|
|
|
aggregateTimeout: 300,
|
|
|
|
poll: 500
|
|
|
|
},
|
|
|
|
public: url.parse(config.callback_url).hostname
|
2019-01-27 20:29:33 +00:00
|
|
|
},
|
|
|
|
plugins: [
|
2019-06-03 14:51:11 +00:00
|
|
|
new CopyWebpackPlugin([{
|
|
|
|
from: "public"
|
|
|
|
}]),
|
2019-01-27 20:29:33 +00:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
title: 'SecureNotes',
|
|
|
|
template: "./src/index.html"
|
|
|
|
}),
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: "[name].css",
|
|
|
|
chunkFilename: "[id].css"
|
|
|
|
}),
|
|
|
|
new BundleAnalyzerPlugin({
|
|
|
|
analyzerMode: "static",
|
|
|
|
openAnalyzer: false
|
|
|
|
}),
|
|
|
|
new Visualizer(),
|
|
|
|
],
|
2019-06-03 14:51:11 +00:00
|
|
|
entry: {
|
|
|
|
main: "./src/index.tsx"
|
|
|
|
},
|
2019-01-27 20:29:33 +00:00
|
|
|
// Enable sourcemaps for debugging webpack's output.
|
|
|
|
devtool: "eval",
|
|
|
|
resolve: {
|
|
|
|
// Add '.ts' and '.tsx' as resolvable extensions.
|
2019-06-03 14:51:11 +00:00
|
|
|
extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js", ".mjs"]
|
2019-01-27 20:29:33 +00:00
|
|
|
},
|
|
|
|
module: {
|
2019-06-03 14:51:11 +00:00
|
|
|
rules: [{
|
2019-01-27 20:29:33 +00:00
|
|
|
test: /\.tsx?$/,
|
|
|
|
use: 'ts-loader',
|
|
|
|
exclude: /node_modules/
|
|
|
|
}, {
|
|
|
|
test: /\.(png|jpg)$/,
|
|
|
|
loader: "file-loader",
|
|
|
|
}, {
|
2019-03-25 01:25:08 +00:00
|
|
|
test: /\.(scss|css)$/,
|
2019-01-27 20:29:33 +00:00
|
|
|
use: [
|
|
|
|
"style-loader", // creates style nodes from JS strings
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
"css-loader", // translates CSS into CommonJS
|
|
|
|
"sass-loader" // compiles Sass to CSS, using Node Sass by default
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.svg$/,
|
|
|
|
use: ['preact-svg-loader'],
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|