-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
109 lines (106 loc) · 3 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
const path = require('path');
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const htmlPlugin = new HtmlWebPackPlugin({
template: './src/index.html',
filename: path.resolve(__dirname, 'build', 'index.html'),
title: 'Caching'
});
const miniCssExtractPlugin = new MiniCssExtractPlugin({
filename: 'css/style.[contenthash].css'
});
const copyWebpackPlugin = new CopyWebpackPlugin({
patterns: [
{ from: 'public', to: 'public', toType: 'dir' },
{
from: 'node_modules/@janelia-flyem/neuroglancer/dist/module/chunk_worker.bundle.js',
to: 'chunk_worker.bundle.js',
toType: 'file'
},
{
from: 'node_modules/@janelia-flyem/neuroglancer/dist/module/async_computation.bundle.js',
to: 'async_computation.bundle.js',
toType: 'file'
},
{
from: 'node_modules/@janelia-flyem/neuroglancer/dist/module/main.css',
to: 'ng.css',
toType: 'file'
},
{
from: 'public/mockServiceWorker.js',
to: 'mockServiceWorker.js',
toType: 'file'
},
]
});
module.exports = {
entry: {
app: './src/js/app.jsx'
},
plugins: [
htmlPlugin,
new CleanWebpackPlugin({ cleanAfterEveryBuildPatterns: ['build']}),
miniCssExtractPlugin,
copyWebpackPlugin,
new webpack.DefinePlugin({
VERSION: JSON.stringify(require('./package.json').version),
PUBLIC: 'false'
})
],
output: {
path: path.resolve(__dirname, 'build'),
filename: 'js/[name].[contenthash].bundle.js',
chunkFilename: 'js/[name].[contenthash].bundle.js',
publicPath: '/'
},
mode: 'development',
watch: true,
devtool: 'source-map',
devServer: {
static: './build'
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: [/node_modules/],
use: ['babel-loader']
},
{
test: /\.jsx?$/,
use: ['source-map-loader'],
exclude: [/node_modules\/@janelia-flyem\/neuroglancer/, /node_modules\/swagger-client/],
enforce: 'pre'
},
{
test: /\.svg$/,
loader: require.resolve('svg-inline-loader'),
options: {removeSVGTagAttrs: false, removeTags: true}
},
{
test: /\.(png|jpg|gif)$/,
use: ['file-loader']
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
}
]
},
resolve: {
alias: {
containers: path.resolve(__dirname, 'src/js/containers'),
components: path.resolve(__dirname, 'src/js/components'),
helpers: path.resolve(__dirname, 'src/js/helpers'),
plugins: path.resolve(__dirname, 'src/js/plugins'),
views: path.resolve(__dirname, 'src/js/components/view-plugins'),
actions: path.resolve(__dirname, 'src/js/actions')
},
symlinks: false,
extensions: ['.js', '.jsx', '.react.js']
}
};