-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
110 lines (108 loc) · 3.16 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackIncludeAssetsPlugin = require('html-webpack-include-assets-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const externalAssets = [
'solid-auth-client/dist-popup/popup.html',
'rdflib/dist/rdflib.min.js',
'solid-auth-client/dist-lib/solid-auth-client.bundle.js',
'solid-auth-client/dist-lib/solid-auth-client.bundle.js.map'
];
module.exports = {
entry: './src/index.js',
mode: 'development',
module: {
exprContextCritical: false,
rules: [
{
test: /\.html$/,
loader: 'file-loader?name=[name].[ext]',
},
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
options: {
presets: ['@babel/env', '@babel/preset-react', '@babel/preset-flow'],
plugins: ["react-hot-loader/babel", "@babel/plugin-proposal-class-properties", "@babel/plugin-transform-runtime"]
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.scss$/,
use: [
'style-loader', // creates style nodes from JS strings
'css-loader', // translates CSS into CommonJS
'sass-loader', // compiles Sass to CSS, using Node Sass by default
{
loader: 'sass-resources-loader',
options: {
resources: [
'node_modules/purecss-sass/vendor/assets/stylesheets/purecss/_base.scss',
'node_modules/purecss-sass/vendor/assets/stylesheets/purecss/_grids.scss',
'node_modules/purecss-sass/vendor/assets/stylesheets/purecss/_grids-responsive.scss',
'src/theme/main.scss'
]
}
}
]
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
}
}]
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
outputPath: 'img/',
publicPath: 'public/assets/img/'
}
}
]
}
]
},
resolve: { extensions: ['*', '.js', '.jsx'] },
externals: {
'node-fetch': 'fetch',
'text-encoding': 'TextEncoder',
'whatwg-url': 'window',
'isomorphic-fetch': 'fetch',
'@trust/webcrypto': 'crypto'
},
output: {
path: path.resolve(__dirname, 'dist/'),
publicPath: '/dist/',
filename: 'bundle.js'
},
devServer: {
contentBase: path.join(__dirname, 'public/'),
port: 3100,
publicPath: 'http://localhost:3000/dist/',
historyApiFallback: true,
hot: true
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new CopyWebpackPlugin(externalAssets.map(a => require.resolve(a))),
new HtmlWebpackIncludeAssetsPlugin({
assets: [
...externalAssets.map(f => f.replace(/.*\//, ''))
].filter(f => /\.(js|css|scss)$/.test(f)),
append: false
})
]
};