This repository has been archived by the owner on Sep 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
51 lines (46 loc) · 1.52 KB
/
webpack.config.ts
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
/**
* Don't forget to run the DLL config for WebPack first for correct DLL references
*/
import * as AutoPrefixer from "autoprefixer";
import { loader as MiniCssExtractPluginLoader } from "mini-css-extract-plugin";
import { Configuration as WebpackConfig } from "webpack";
import devConfig from "./webpack/development";
import prodConfig from "./webpack/production";
const config = (env: any, argv: WebpackConfig): WebpackConfig => {
/**
* The common WebPack configuration no matter what environment it is run on
*/
const commonConfig: WebpackConfig = {
entry: {
app: "./src/ts/index.ts",
},
mode: argv.mode,
module: {
rules: [{
exclude: /node_modules/,
test: /\.ts?$/,
use: "ts-loader", // Change to loader: "ts-loader" if you need to pass options
}, {
test: /\.scss$/,
use: [
argv.mode === "production" ? MiniCssExtractPluginLoader : "style-loader",
"css-loader?sourceMap",
{ loader: "postcss-loader", options: { plugins: [AutoPrefixer] } },
"sass-loader?sourceMap",
],
}, {
test: /\.(eot|svg|ttf|otf|woff|woff2)$/,
use: "file-loader?name=[name].[ext]",
}],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
};
const additionalConfig = argv.mode === "production" ? prodConfig(__dirname) : devConfig(__dirname);
/**
* Merge the common configuration with environment-specific ones
*/
return { ...commonConfig, ...additionalConfig };
};
export default config;