-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
86 lines (81 loc) · 2.35 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
// webpack.config.js
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const config = {
// ... other configuration options ...
entry: [
// path.resolve(__dirname, 'src', 'index.js'),
path.resolve(__dirname, 'src', 'index.scss')
],
output: {
path: path.join(__dirname, 'dist'), // bundled file in dist/
filename: '[name].js'
},
module: {
rules: [
{
test: /\.js$/, // applies to js files
use: ["babel-loader"], // transpiles your js
exclude: /node_modules/, // don't transpile node modules
},
{
test: /\.s?[ac]ss$/, // applies to css/scss/sass files
use: [
MiniCssExtractPlugin.loader, // create bundled css file
{
loader: "css-loader", // resolves @import statements
options: { url: false }, // don't resolve url() statements
},
"sass-loader", // compiles sass to css
],
},
{
test: /\.(png|jpe?g|gif)$/i,
loader: "file-loader",
options: {
name: "[path][name].[ext]",
},
},
],
},
plugins: [new MiniCssExtractPlugin()],
};
module.exports = (env, argv) => {
if (argv.mode === 'production') {
config.devtool = 'source-map';
} else {
config.devtool = 'eval-source-map';
}
return config;
}
// const config = {
// // ... other configuration options ...
// module: {
// rules: [
// {
// test: /\.js$/, // applies to js files
// use: ["babel-loader"], // transpiles your js
// exclude: /node_modules/, // don't transpile node modules
// },
// {
// test: /\.s?[ac]ss$/, // applies to css/scss/sass files
// use: [
// MiniCssExtractPlugin.loader, // create bundled css file
// {
// loader: "css-loader", // resolves @import statements
// options: { url: false }, // don't resolve url() statements
// },
// "sass-loader", // compiles sass to css
// ],
// },
// {
// test: /\.(png|jpe?g|gif)$/i,
// loader: "file-loader",
// options: {
// name: "[path][name].[ext]",
// },
// },
// ],
// },
// plugins: [new MiniCssExtractPlugin()],
// };