-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.cjs
130 lines (125 loc) · 3.84 KB
/
webpack.config.cjs
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const webpack = require('webpack')
const path = require('path')
const fs = require('fs')
const appDirectory = fs.realpathSync(process.cwd())
const resolveAppPath = (relativePath) => path.resolve(appDirectory, relativePath)
//Added per https://www.developerhandbook.com/webpack/how-to-configure-scss-modules-for-webpack/
// const isDevelopment = process.env.NODE_ENV === 'development';
// const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
mode: 'development', // switch to production when you package for production - impacts final size of package you import
target: 'web',
entry: {
fpsReactComponents: path.resolve(__dirname, 'src/index.ts'), // npmReactComponents is the name of the library - external cdn reference name: myServices.js
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js', // [name] Comes from entry
publicPath: '/assets/',
library: { type: 'amd' }, // Used by SPFx
clean: true,
},
devtool: 'inline-source-map',
resolve: {
extensions: ['.ts', '.tsx', '.js'],
modules: ['node_modules'],
},
module: {
rules: [
{
test: /\.(css|s[ac]ss)$/i,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
{
test: /\.tsx|.ts?$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: {
happyPackMode: true,
transpileOnly: true,
},
},
],
},
{
test: /\.svg/,
type: 'asset/resource',
},
],
},
externals: {
// Read webpack documentation - do not want to bundle these into the package
react: 'React',
// "lodash-es": "lodash-es/*", //JT added it but it is not being used... so it is an example.
// In the end, I want final this to come from final web part since it already has to have it
// Is this the correct way to reference it?
// If I do this and my SPFx project does not have one, will it figure that out and then add it as a dependancy for me automatically?
// Or will I have to remember to do it downstream
// And to get all typings etc in here from @microsoft, fabric-react, do I install it as dependancy in this package?
'@microsoft/sp-property-pane': '*',
'office-ui-fabric-react': '*', //My actual component import: import { Slider } from 'office-ui-fabric-react/lib/Slider';
'@mikezimm/fps-js': '*',
'@mikezimm/fps-pnp2': '*',
},
devServer: {
compress: true,
hot: true,
port: 3000,
static: {
directory: resolveAppPath('app'),
publicPath: '/',
},
},
// plugins: [
// //... https://www.developerhandbook.com/webpack/how-to-configure-scss-modules-for-webpack/
// new MiniCssExtractPlugin({
// filename: isDevelopment ? '[name].css' : '[name].[hash].css',
// chunkFilename: isDevelopment ? '[id].css' : '[id].[hash].css'
// })
// ],
// module: {
// rules: [
// //... https://www.developerhandbook.com/webpack/how-to-configure-scss-modules-for-webpack/
// {
// test: /\.module\.s(a|c)ss$/,
// loader: [
// isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
// {
// loader: 'css-loader',
// options: {
// modules: true,
// sourceMap: isDevelopment
// }
// },
// {
// loader: 'sass-loader',
// options: {
// sourceMap: isDevelopment
// }
// }
// ]
// },
// {
// test: /\.s(a|c)ss$/,
// exclude: /\.module.(s(a|c)ss)$/,
// loader: [
// isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
// 'css-loader',
// {
// loader: 'sass-loader',
// options: {
// sourceMap: isDevelopment
// }
// }
// ]
// }
// //...
// ]
// },
// resolve: {
// extensions: ['.js', '.jsx'],
// extensions: ['.js', '.jsx', '.scss']
// }
}