forked from canonical/snapcraft.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.rules.js
88 lines (87 loc) · 2.76 KB
/
webpack.config.rules.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
module.exports = [
{
test: /\.js$/,
// Exclude node_modules from using babel-loader
// except some that use ES6 modules and need to be transpiled:
// such as swiper http://idangero.us/swiper/get-started/
// and also react-dnd related
exclude:
/node_modules\/(?!(dom7|ssr-window|swiper|dnd-core|react-dnd|react-dnd-html5-backend)\/).*/,
use: {
loader: "babel-loader",
},
},
{
test: /\.s[ac]ss$/i,
use: ["style-loader", "css-loader", "sass-loader"],
},
// TODO:
// we should get rid of using globals making expose-loader unnecessary
// https://github.com/canonical-web-and-design/snapcraft.io/issues/1245
// loaders are evaluated from bottom to top (right to left)
// so first transpile via babel, then expose as global
{
test: require.resolve(__dirname + "/static/js/base/base.ts"),
use: ["expose-loader?exposes=snapcraft.base", "babel-loader"],
},
{
test: require.resolve(__dirname + "/static/js/publisher/release.tsx"),
use: ["expose-loader?exposes=snapcraft.release", "babel-loader"],
},
{
test: require.resolve(__dirname + "/static/js/publisher/publisher.ts"),
use: ["expose-loader?exposes=snapcraft.publisher", "babel-loader"],
},
{
test: require.resolve(__dirname + "/static/js/public/about/index.ts"),
use: ["expose-loader?exposes=snapcraft.about", "babel-loader"],
},
{
test: require.resolve(__dirname + "/static/js/public/featured-snaps.ts"),
use: [
"expose-loader?exposes=snapcraft.public.featuredSnaps",
"babel-loader",
],
},
{
test: require.resolve(__dirname + "/static/js/public/modal.ts"),
use: ["expose-loader?exposes=snapcraft.public.modal", "babel-loader"],
},
{
test: require.resolve(__dirname + "/static/js/public/homepage.ts"),
use: ["expose-loader?exposes=snapcraft.public.homepage", "babel-loader"],
},
{
test: require.resolve(__dirname + "/static/js/public/blog.ts"),
use: ["expose-loader?exposes=snapcraft.public.blog", "babel-loader"],
},
{
test: require.resolve(__dirname + "/static/js/public/store-details.ts"),
use: [
"expose-loader?exposes=snapcraft.public.storeDetails",
"babel-loader",
],
},
{
test: require.resolve(__dirname + "/static/js/public/fsf.ts"),
use: ["expose-loader?exposes=snapcraft.public.fsf", "babel-loader"],
},
{
test: require.resolve(__dirname + "/static/js/public/distro-install.ts"),
use: [
"expose-loader?exposes=snapcraft.public.distroInstall",
"babel-loader",
],
},
{
test: require.resolve(__dirname + "/static/js/public/publisher-details.ts"),
use: [
"expose-loader?exposes=snapcraft.public.publisherDetails",
"babel-loader",
],
},
{
test: /\.tsx?/,
use: ["ts-loader"],
},
];