forked from TheodoreChu/append-editor
/
webpack.config.js
90 lines (89 loc) · 2.51 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const webpack = require('webpack');
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ProposalClassProperties = require('@babel/plugin-proposal-class-properties');
module.exports = {
mode: 'production',
devtool: 'cheap-source-map',
devServer: {
disableHostCheck: true,
historyApiFallback: true,
watchOptions: { aggregateTimeout: 300, poll: 1000 },
},
entry: [
path.resolve(__dirname, 'app/main.js'),
path.resolve(__dirname, 'app/stylesheets/main.scss'),
],
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: './dist.js',
},
module: {
rules: [
{
test: /\.s?css$/,
include: path.resolve(__dirname, 'app'),
loader: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
{
test: /\.js[x]?$/,
include: [
path.resolve(__dirname, 'app'),
path.resolve(
__dirname,
'node_modules/sn-components-api/dist/dist.js'
),
],
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
},
},
],
},
externals: {
'filesafe-js': 'filesafe-js',
},
resolve: {
modules: ['node_modules', path.resolve(__dirname, 'app')],
extensions: ['.js', '.jsx', '.css', '.scss'],
alias: {
stylekit: path.join(
__dirname,
'node_modules/sn-stylekit/dist/stylekit.css'
),
codemirror: path.join(__dirname, 'node_modules/codemirror/'),
codemirrordialog: path.join(
__dirname,
'node_modules/codemirror/addon/dialog/dialog.css'
),
codemirrormatchesonscrollbar: path.join(
__dirname,
'node_modules/codemirror/addon/search/matchesonscrollbar.css'
),
},
},
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: 'dist.css',
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
new CopyWebpackPlugin({
patterns: [
{ from: './app/index.html', to: 'index.html' },
// You don't need to do this every time, only after you update dependencies
{
from: path.resolve(__dirname, './node_modules/katex/dist'),
to: 'katex/latest',
},
],
}),
],
};