Updated to 1.13.1 sfpx version

This commit is contained in:
Alberto Gutierrez 2022-01-02 12:26:04 +00:00
parent c6ade94e23
commit 9fc3ad544b
19 changed files with 14730 additions and 8427 deletions

View File

@ -1,25 +0,0 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
# change these settings to your own preference
indent_style = space
indent_size = 2
# we recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
[{package,bower}.json]
indent_style = space
indent_size = 2

View File

@ -9,6 +9,7 @@ node_modules
# Build generated files
dist
lib
release
solution
temp
*.sppkg
@ -30,4 +31,4 @@ obj
# Styles Generated Code
*.scss.ts
*.scss.d.ts
*.scss.d.ts

View File

@ -0,0 +1,16 @@
!dist
config
gulpfile.js
release
src
temp
tsconfig.json
tslint.json
*.log
.yo-rc.json
.vscode

View File

@ -1,6 +1,6 @@
{
"@microsoft/generator-sharepoint": {
"version": "1.11.0",
"version": "1.13.1",
"libraryName": "list-search-webpart",
"libraryId": "8277f088-9c30-4f95-9c15-9c18a9d40a26",
"environment": "spo",

View File

@ -58,8 +58,8 @@ This list search web part allows the user to show data from lists or libraries.
## Compatibility
![SPFx 1.11](https://img.shields.io/badge/SPFx-1.11.0-green.svg)
![Node.js v10](https://img.shields.io/badge/Node.js-v10-green.svg)
![SPFx 1.13.1](https://img.shields.io/badge/SPFx-1.13.1-green.svg)
![Node.js v14](https://img.shields.io/badge/Node.js-v14-green.svg)
![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg)
![Does not work with SharePoint 2019](https://img.shields.io/badge/SharePoint%20Server%202019-Incompatible-red.svg "SharePoint Server 2019 requires SPFx 1.4.1 or lower")
![Does not work with SharePoint 2016 (Feature Pack 2)](https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202)-Incompatible-red.svg "SharePoint Server 2016 Feature Pack 2 requires SPFx 1.1")
@ -84,6 +84,7 @@ Version|Date|Comments
-------|----|--------
1.0.0|December 20, 2020|Initial release
1.1.0|April 25, 2021|List item modern audience support
1.2.0|January 01, 2022|Upgraded for SPFx v1.13.1
## Minimal Path to Awesome

View File

@ -1,4 +0,0 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
"deployCdnPath": "temp/deploy"
}

View File

@ -1,7 +1,7 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"workingDir": "./temp/deploy/",
"workingDir": "./release/assets/",
"account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "list-search-webpart",
"accessKey": "<!-- ACCESS KEY -->"
}
}

View File

@ -3,7 +3,7 @@
"solution": {
"name": "list-search-webpart",
"id": "8277f088-9c30-4f95-9c15-9c18a9d40a26",
"version": "1.1.0.0",
"version": "1.2.0.0",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": false,

View File

@ -2,9 +2,5 @@
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
"port": 4321,
"https": true,
"initialPage": "https://localhost:5432/workbench",
"api": {
"port": 5432,
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
}
"initialPage": "https://enter-your-SharePoint-site/_layouts/workbench.aspx"
}

View File

@ -0,0 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/s-KaiNet/spfx-fast-serve/master/schema/config.latest.schema.json",
"cli": {
"isLibraryComponent": false
}
}

View File

@ -0,0 +1,24 @@
/*
* User webpack settings file. You can add your own settings here.
* Changes from this file will be merged into the base webpack configuration file.
* This file will not be overwritten by the subsequent spfx-fast-serve calls.
*/
// you can add your project related webpack configuration here, it will be merged using webpack-merge module
// i.e. plugins: [new webpack.Plugin()]
const webpackConfig = {
}
// for even more fine-grained control, you can apply custom webpack settings using below function
const transformConfig = function (initialWebpackConfig) {
// transform the initial webpack config here, i.e.
// initialWebpackConfig.plugins.push(new webpack.Plugin()); etc.
return initialWebpackConfig;
}
module.exports = {
webpackConfig,
transformConfig
}

View File

@ -4,33 +4,20 @@ const build = require('@microsoft/sp-build-web');
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
const argv = build.rig.getYargs().argv;
const useCustomServe = argv['custom-serve'];
const fs = require("fs");
const workbenchApi = require("@microsoft/sp-webpart-workbench/lib/api");
var getTasks = build.rig.getTasks;
build.rig.getTasks = function () {
var result = getTasks.call(build.rig);
if (useCustomServe) {
build.tslintCmd.enabled = false;
const ensureWorkbenchSubtask = build.subTask('ensure-workbench-task', function (gulp, buildOptions, done) {
this.log('Creating workbench.html file...');
try {
workbenchApi.default["/workbench"]();
} catch (e) { }
result.set('serve', result.get('serve-deprecated'));
done();
});
return result;
};
build.rig.addPostBuildTask(build.task('ensure-workbench', ensureWorkbenchSubtask));
/* fast-serve */
const { addFastServe } = require("spfx-fast-serve-helpers");
addFastServe(build);
/* end of fast-serve */
build.initialize(require('gulp'));
build.configureWebpack.mergeConfig({
additionalConfiguration: (generatedConfiguration) => {
fs.writeFileSync("./temp/_webpack_config.json", JSON.stringify(generatedConfiguration, null, 2));
return generatedConfiguration;
}
});
}
build.initialize(require('gulp'));

File diff suppressed because it is too large Load Diff

View File

@ -3,60 +3,43 @@
"version": "1.0.0",
"private": true,
"main": "lib/index.js",
"engines": {
"node": ">=0.10.0"
},
"engines": "undefined",
"scripts": {
"build": "gulp bundle",
"clean": "gulp clean",
"test": "gulp test",
"alldebug": "gulp clean && gulp build && gulp bundle && gulp serve",
"allpackage": "gulp clean && gulp build --ship && gulp bundle --ship && gulp package-solution --ship",
"serve": "cross-env NODE_OPTIONS=--max_old_space_size=4096 gulp bundle --custom-serve && cross-env NODE_OPTIONS=--max_old_space_size=4096 webpack-dev-server --mode development --config ./webpack.js --env.env=dev",
"publish-please": "publish-please",
"prepublishOnly": "publish-please guard"
"prepublishOnly": "publish-please guard",
"serve": "gulp bundle --custom-serve --max_old_space_size=4096 && fast-serve"
},
"dependencies": {
"@microsoft/sp-core-library": "1.11.0",
"@microsoft/sp-lodash-subset": "1.11.0",
"@microsoft/sp-office-ui-fabric-core": "1.11.0",
"@microsoft/sp-property-pane": "1.11.0",
"@microsoft/sp-webpart-base": "1.11.0",
"@microsoft/sp-core-library": "1.13.1",
"@microsoft/sp-lodash-subset": "1.13.1",
"@microsoft/sp-office-ui-fabric-core": "1.13.1",
"@microsoft/sp-property-pane": "1.13.1",
"@microsoft/sp-webpart-base": "1.13.1",
"@pnp/graph": "2.4.0",
"@pnp/sp": "2.0.8",
"@pnp/spfx-controls-react": "2.4.0",
"@pnp/spfx-property-controls": "2.5.0",
"office-ui-fabric-react": "7.155.3",
"react": "16.8.5",
"react-dom": "16.8.5",
"office-ui-fabric-react": "7.174.1",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-js-pagination": "3.0.3",
"react-xml-parser": "1.1.6"
},
"devDependencies": {
"@microsoft/sp-build-web": "1.11.0",
"@microsoft/sp-tslint-rules": "1.11.0",
"@microsoft/sp-module-interfaces": "1.11.0",
"@microsoft/sp-webpart-workbench": "1.11.0",
"@microsoft/rush-stack-compiler-3.3": "0.3.5",
"gulp": "~3.9.1",
"@types/chai": "3.4.34",
"@types/mocha": "2.2.38",
"ajv": "~5.2.2",
"@microsoft/rush-stack-compiler-3.9": "0.4.47",
"@microsoft/sp-build-web": "1.13.1",
"@microsoft/sp-module-interfaces": "1.13.1",
"@microsoft/sp-tslint-rules": "1.13.1",
"@types/react": "16.9.51",
"@types/react-dom": "16.9.8",
"@types/webpack-env": "1.13.1",
"@types/es6-promise": "0.0.33",
"css-loader": "3.4.2",
"css-modules-typescript-loader": "4.0.0",
"fork-ts-checker-webpack-plugin": "4.1.0",
"node-sass": "4.13.1",
"sass-loader": "8.0.2",
"style-loader": "1.1.3",
"ts-loader": "6.2.1",
"webpack": "4.42.0",
"webpack-cli": "3.3.11",
"webpack-dev-server": "3.10.3",
"del": "5.1.0",
"cross-env": "7.0.2",
"@types/react": "16.8.8",
"@types/react-dom": "16.8.3"
"ajv": "~5.2.2",
"gulp": "4.0.2",
"spfx-fast-serve-helpers": "~1.13.0"
}
}

View File

@ -823,7 +823,7 @@ export default class ListSearchWebPart extends BaseClientSideWebPart<IListSearch
PropertyFieldSitePicker('sites', {
label: strings.SitesSelector,
initialSites: this.properties.sites || [],
context: this.context,
context: this.context as any,
multiSelect: true,
onPropertyChange: (propertyPath, oldValue, newValue) => this.onPropertyPaneFieldChanged(propertyPath, oldValue, newValue),
properties: this.properties,

View File

@ -1,5 +1,5 @@
{
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json",
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.9/includes/tsconfig-web.json",
"compilerOptions": {
"target": "es6",
"forceConsistentCasingInFileNames": true,
@ -19,21 +19,18 @@
"./node_modules/@microsoft"
],
"types": [
"es6-promise",
"webpack-env"
],
"lib": [
"es6",
"dom",
"es2015.collection"
"es2015.collection",
"es2015.promise"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx"
],
"exclude": [
"node_modules",
"lib"
]
"exclude": []
}

View File

@ -1,6 +1,5 @@
{
"extends": "@microsoft/sp-tslint-rules/base-tslint.json",
"extends": "./node_modules/@microsoft/sp-tslint-rules/base-tslint.json",
"rules": {
"class-name": false,
"export-name": false,

View File

@ -0,0 +1,594 @@
# Upgrade project react-list-search to v1.13.1
Date: 1/2/2022
## Findings
Following is the list of steps required to upgrade your project to SharePoint Framework version 1.13.1. [Summary](#Summary) of the modifications is included at the end of the report.
### FN001001 @microsoft/sp-core-library | Required
Upgrade SharePoint Framework dependency package @microsoft/sp-core-library
Execute the following command:
```sh
npm i -SE @microsoft/sp-core-library@1.13.1
```
File: [./package.json:20:5](./package.json)
### FN001002 @microsoft/sp-lodash-subset | Required
Upgrade SharePoint Framework dependency package @microsoft/sp-lodash-subset
Execute the following command:
```sh
npm i -SE @microsoft/sp-lodash-subset@1.13.1
```
File: [./package.json:21:5](./package.json)
### FN001003 @microsoft/sp-office-ui-fabric-core | Required
Upgrade SharePoint Framework dependency package @microsoft/sp-office-ui-fabric-core
Execute the following command:
```sh
npm i -SE @microsoft/sp-office-ui-fabric-core@1.13.1
```
File: [./package.json:22:5](./package.json)
### FN001004 @microsoft/sp-webpart-base | Required
Upgrade SharePoint Framework dependency package @microsoft/sp-webpart-base
Execute the following command:
```sh
npm i -SE @microsoft/sp-webpart-base@1.13.1
```
File: [./package.json:24:5](./package.json)
### FN001021 @microsoft/sp-property-pane | Required
Upgrade SharePoint Framework dependency package @microsoft/sp-property-pane
Execute the following command:
```sh
npm i -SE @microsoft/sp-property-pane@1.13.1
```
File: [./package.json:23:5](./package.json)
### FN002001 @microsoft/sp-build-web | Required
Upgrade SharePoint Framework dev dependency package @microsoft/sp-build-web
Execute the following command:
```sh
npm i -DE @microsoft/sp-build-web@1.13.1
```
File: [./package.json:36:5](./package.json)
### FN002002 @microsoft/sp-module-interfaces | Required
Upgrade SharePoint Framework dev dependency package @microsoft/sp-module-interfaces
Execute the following command:
```sh
npm i -DE @microsoft/sp-module-interfaces@1.13.1
```
File: [./package.json:38:5](./package.json)
### FN002009 @microsoft/sp-tslint-rules | Required
Upgrade SharePoint Framework dev dependency package @microsoft/sp-tslint-rules
Execute the following command:
```sh
npm i -DE @microsoft/sp-tslint-rules@1.13.1
```
File: [./package.json:37:5](./package.json)
### FN010001 .yo-rc.json version | Recommended
Update version in .yo-rc.json
```json
{
"@microsoft/generator-sharepoint": {
"version": "1.13.1"
}
}
```
File: [./.yo-rc.json:3:5](./.yo-rc.json)
### FN001008 react | Required
Upgrade SharePoint Framework dependency package react
Execute the following command:
```sh
npm i -SE react@16.13.1
```
File: [./package.json:30:5](./package.json)
### FN001009 react-dom | Required
Upgrade SharePoint Framework dependency package react-dom
Execute the following command:
```sh
npm i -SE react-dom@16.13.1
```
File: [./package.json:31:5](./package.json)
### FN001022 office-ui-fabric-react | Required
Upgrade SharePoint Framework dependency package office-ui-fabric-react
Execute the following command:
```sh
npm i -SE office-ui-fabric-react@7.174.1
```
File: [./package.json:29:5](./package.json)
### FN002003 @microsoft/sp-webpart-workbench | Required
Remove SharePoint Framework dev dependency package @microsoft/sp-webpart-workbench
Execute the following command:
```sh
npm un -D @microsoft/sp-webpart-workbench
```
File: [./package.json:39:5](./package.json)
### FN002015 @types/react | Required
Upgrade SharePoint Framework dev dependency package @types/react
Execute the following command:
```sh
npm i -DE @types/react@16.9.51
```
File: [./package.json:59:5](./package.json)
### FN002018 @microsoft/rush-stack-compiler-3.9 | Required
Install SharePoint Framework dev dependency package @microsoft/rush-stack-compiler-3.9
Execute the following command:
```sh
npm i -DE @microsoft/rush-stack-compiler-3.9@0.4.47
```
File: [./package.json:35:3](./package.json)
### FN007002 serve.json initialPage | Required
Update serve.json initialPage URL
```json
{
"initialPage": "https://enter-your-SharePoint-site/_layouts/workbench.aspx"
}
```
File: [./config/serve.json:5:3](./config/serve.json)
### FN007003 serve.json api | Required
From serve.json remove the api property
```json
```
File: [./config/serve.json:6:3](./config/serve.json)
### FN012017 tsconfig.json extends property | Required
Update tsconfig.json extends property
```json
{
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.9/includes/tsconfig-web.json"
}
```
File: [./tsconfig.json:2:3](./tsconfig.json)
### FN015007 config/copy-assets.json | Required
Remove file config/copy-assets.json
Execute the following command:
```sh
rm "config/copy-assets.json"
```
File: [config/copy-assets.json](config/copy-assets.json)
### FN024001 Create .npmignore | Required
Create the .npmignore file
File: [./.npmignore](./.npmignore)
### FN005002 deploy-azure-storage.json workingDir | Required
Update deploy-azure-storage.json workingDir
```json
{
"workingDir": "./release/assets/"
}
```
File: [./config/deploy-azure-storage.json:3:3](./config/deploy-azure-storage.json)
### FN023001 .gitignore 'release' folder | Required
To .gitignore add the 'release' folder
File: [./.gitignore](./.gitignore)
### FN002004 gulp | Required
Upgrade SharePoint Framework dev dependency package gulp
Execute the following command:
```sh
npm i -DE gulp@4.0.2
```
File: [./package.json:41:5](./package.json)
### FN002005 @types/chai | Required
Remove SharePoint Framework dev dependency package @types/chai
Execute the following command:
```sh
npm un -D @types/chai
```
File: [./package.json:42:5](./package.json)
### FN002006 @types/mocha | Required
Remove SharePoint Framework dev dependency package @types/mocha
Execute the following command:
```sh
npm un -D @types/mocha
```
File: [./package.json:43:5](./package.json)
### FN002014 @types/es6-promise | Required
Remove SharePoint Framework dev dependency package @types/es6-promise
Execute the following command:
```sh
npm un -D @types/es6-promise
```
File: [./package.json:46:5](./package.json)
### FN002016 @types/react-dom | Required
Upgrade SharePoint Framework dev dependency package @types/react-dom
Execute the following command:
```sh
npm i -DE @types/react-dom@16.9.8
```
File: [./package.json:60:5](./package.json)
### FN012013 tsconfig.json exclude property | Required
Remove tsconfig.json exclude property
```json
{
"exclude": []
}
```
File: [./tsconfig.json:35:3](./tsconfig.json)
### FN012018 tsconfig.json es2015.promise lib | Required
Add es2015.promise lib in tsconfig.json
```json
{
"compilerOptions": {
"lib": [
"es2015.promise"
]
}
}
```
File: [./tsconfig.json:25:5](./tsconfig.json)
### FN012019 tsconfig.json es6-promise types | Required
Remove es6-promise type in tsconfig.json
```json
{
"compilerOptions": {
"types": [
"es6-promise"
]
}
}
```
File: [./tsconfig.json:22:7](./tsconfig.json)
### FN013002 gulpfile.js serve task | Required
Before 'build.initialize(require('gulp'));' add the serve task
```js
var getTasks = build.rig.getTasks;
build.rig.getTasks = function () {
var result = getTasks.call(build.rig);
result.set('serve', result.get('serve-deprecated'));
return result;
};
```
File: [./gulpfile.js](./gulpfile.js)
### FN015006 .editorconfig | Required
Remove file .editorconfig
Execute the following command:
```sh
rm ".editorconfig"
```
File: [.editorconfig](.editorconfig)
### FN019002 tslint.json extends | Required
Update tslint.json extends property
```json
{
"extends": "./node_modules/@microsoft/sp-tslint-rules/base-tslint.json"
}
```
File: [./tslint.json:2:3](./tslint.json)
### FN021002 engines | Required
Remove package.json property
```json
{
"engines": "undefined"
}
```
File: [./package.json:6:3](./package.json)
### FN017001 Run npm dedupe | Optional
If, after upgrading npm packages, when building the project you have errors similar to: "error TS2345: Argument of type 'SPHttpClientConfiguration' is not assignable to parameter of type 'SPHttpClientConfiguration'", try running 'npm dedupe' to cleanup npm packages.
Execute the following command:
```sh
npm dedupe
```
File: [./package.json](./package.json)
## Summary
### Execute script
```sh
npm un -D @microsoft/sp-webpart-workbench @types/chai @types/mocha @types/es6-promise
npm i -SE @microsoft/sp-core-library@1.13.1 @microsoft/sp-lodash-subset@1.13.1 @microsoft/sp-office-ui-fabric-core@1.13.1 @microsoft/sp-webpart-base@1.13.1 @microsoft/sp-property-pane@1.13.1 react@16.13.1 react-dom@16.13.1 office-ui-fabric-react@7.174.1
npm i -DE @microsoft/sp-build-web@1.13.1 @microsoft/sp-module-interfaces@1.13.1 @microsoft/sp-tslint-rules@1.13.1 @types/react@16.9.51 @microsoft/rush-stack-compiler-3.9@0.4.47 gulp@4.0.2 @types/react-dom@16.9.8
npm dedupe
rm "config/copy-assets.json"
rm ".editorconfig"
```
### Modify files
#### [./.yo-rc.json](./.yo-rc.json)
Update version in .yo-rc.json:
```json
{
"@microsoft/generator-sharepoint": {
"version": "1.13.1"
}
}
```
#### [./config/serve.json](./config/serve.json)
Update serve.json initialPage URL:
```json
{
"initialPage": "https://enter-your-SharePoint-site/_layouts/workbench.aspx"
}
```
From serve.json remove the api property:
```json
```
#### [./tsconfig.json](./tsconfig.json)
Update tsconfig.json extends property:
```json
{
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.9/includes/tsconfig-web.json"
}
```
Remove tsconfig.json exclude property:
```json
{
"exclude": []
}
```
Add es2015.promise lib in tsconfig.json:
```json
{
"compilerOptions": {
"lib": [
"es2015.promise"
]
}
}
```
Remove es6-promise type in tsconfig.json:
```json
{
"compilerOptions": {
"types": [
"es6-promise"
]
}
}
```
#### [./.npmignore](./.npmignore)
Create the .npmignore file:
```text
!dist
config
gulpfile.js
release
src
temp
tsconfig.json
tslint.json
*.log
.yo-rc.json
.vscode
```
#### [./config/deploy-azure-storage.json](./config/deploy-azure-storage.json)
Update deploy-azure-storage.json workingDir:
```json
{
"workingDir": "./release/assets/"
}
```
#### [./.gitignore](./.gitignore)
To .gitignore add the 'release' folder:
```text
release
```
#### [./gulpfile.js](./gulpfile.js)
Before 'build.initialize(require('gulp'));' add the serve task:
```js
var getTasks = build.rig.getTasks;
build.rig.getTasks = function () {
var result = getTasks.call(build.rig);
result.set('serve', result.get('serve-deprecated'));
return result;
};
```
#### [./tslint.json](./tslint.json)
Update tslint.json extends property:
```json
{
"extends": "./node_modules/@microsoft/sp-tslint-rules/base-tslint.json"
}
```
#### [./package.json](./package.json)
Remove package.json property:
```json
{
"engines": "undefined"
}
```

View File

@ -1,259 +0,0 @@
const path = require("path");
const fs = require("fs");
const webpack = require("webpack");
const resolve = require("path").resolve;
const CertStore = require("@microsoft/gulp-core-build-serve/lib/CertificateStore");
const CertificateStore = CertStore.CertificateStore || CertStore.default;
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
const del = require("del");
const port = 4321;
const host = "https://localhost:" + port;
///
// Transforms define("<guid>", ...) to web part specific define("<web part id_version", ...)
// the same approach is used inside copyAssets SPFx build step
///
class DynamicLibraryPlugin {
constructor(options) {
this.opitons = options;
}
apply(compiler) {
compiler.hooks.emit.tap("DynamicLibraryPlugin", compilation => {
for (const assetId in this.opitons.modulesMap) {
const moduleMap = this.opitons.modulesMap[assetId];
if (compilation.assets[assetId]) {
const rawValue = compilation.assets[assetId].children[0]._value;
compilation.assets[assetId].children[0]._value = rawValue.replace(this.opitons.libraryName, moduleMap.id + "_" + moduleMap.version);
}
}
});
}
}
///
// Removes *.module.scss.ts on the first execution in order prevent conflicts with *.module.scss.d.ts
// generated by css-modules-typescript-loader
///
class ClearCssModuleDefinitionsPlugin {
constructor(options) {
this.options = options || {};
}
apply(compiler) {
compiler.hooks.done.tap("FixStylesPlugin", stats => {
if (!this.options.deleted) {
setTimeout(() => {
del.sync(["src/**/*.module.scss.ts"]);
}, 3000);
this.options.deleted = true;
}
});
}
}
let baseConfig = {
target: "web",
mode: "development",
devtool: "source-map",
resolve: {
extensions: [".ts", ".tsx", ".js"],
modules: ["node_modules"]
},
context: path.resolve(__dirname),
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
options: {
transpileOnly: true,
compilerOptions: {
declarationMap: false
}
},
exclude: /node_modules/
},
{
use: [{
loader: "@microsoft/loader-cased-file",
options: {
name: "[name:lower]_[hash].[ext]"
}
}],
test: /\.(jpe?g|png|woff|eot|ttf|svg|gif|dds)$/i
},
{
use: [{
loader: "html-loader"
}],
test: /\.html$/
},
{
test: /\.css$/,
use: [
{
loader: "@microsoft/loader-load-themed-styles",
options: {
async: true
}
},
{
loader: "css-loader"
}
]
},
{
test: function (fileName) {
return fileName.endsWith(".module.scss"); // scss modules support
},
use: [
{
loader: "@microsoft/loader-load-themed-styles",
options: {
async: true
}
},
"css-modules-typescript-loader",
{
loader: "css-loader",
options: {
modules: {
localIdentName: "[local]_[hash:base64:8]"
}
}
}, // translates CSS into CommonJS
"sass-loader" // compiles Sass to CSS, using Node Sass by default
]
},
{
test: function (fileName) {
return !fileName.endsWith(".module.scss") && fileName.endsWith(".scss"); // just regular .scss
},
use: [
{
loader: "@microsoft/loader-load-themed-styles",
options: {
async: true
}
},
"css-loader", // translates CSS into CommonJS
"sass-loader" // compiles Sass to CSS, using Node Sass by default
]
}
]
},
plugins: [
new ForkTsCheckerWebpackPlugin({
tslint: true
}),
new ClearCssModuleDefinitionsPlugin(),
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
"process.env.DEBUG": JSON.stringify(true),
"DEBUG": JSON.stringify(true)
})],
devServer: {
hot: false,
contentBase: resolve(__dirname),
publicPath: host + "/dist/",
host: "localhost",
port: port,
disableHostCheck: true,
historyApiFallback: true,
open: true,
writeToDisk: false,
openPage: host + "/temp/workbench.html",
stats: {
preset: "errors-only",
colors: true,
chunks: false,
modules: false,
assets: false
},
proxy: { // url re-write for resources to be served directly from src folder
"/lib/**/loc/*.js": {
target: host,
pathRewrite: { "^/lib": "/src" },
secure: false
}
},
headers: {
"Access-Control-Allow-Origin": "*",
},
https: {
cert: CertificateStore.instance.certificateData,
key: CertificateStore.instance.keyData
}
},
}
const createConfig = function () {
// remove old css module TypeScript definitions
del.sync(["dist/*.js", "dist/*.map"]);
// we need only "externals", "output" and "entry" from the original webpack config
let originalWebpackConfig = require("./temp/_webpack_config.json");
baseConfig.externals = originalWebpackConfig.externals;
baseConfig.output = originalWebpackConfig.output;
baseConfig.entry = getEntryPoints(originalWebpackConfig.entry);
baseConfig.output.publicPath = host + "/dist/";
const manifest = require("./temp/manifests.json");
const modulesMap = {};
const originalEntries = Object.keys(originalWebpackConfig.entry);
for (const jsModule of manifest) {
if (jsModule.loaderConfig
&& jsModule.loaderConfig.entryModuleId
&& originalEntries.indexOf(jsModule.loaderConfig.entryModuleId) !== -1) {
modulesMap[jsModule.loaderConfig.entryModuleId + ".js"] = {
id: jsModule.id,
version: jsModule.version
}
}
}
baseConfig.plugins.push(new DynamicLibraryPlugin({
modulesMap: modulesMap,
libraryName: originalWebpackConfig.output.library
}));
return baseConfig;
}
function getEntryPoints(entry) {
// fix: ".js" entry needs to be ".ts"
// also replaces the path form /lib/* to /src/*
let newEntry = {};
let libSearchRegexp;
if (path.sep === "/") {
libSearchRegexp = /\/lib\//gi;
} else {
libSearchRegexp = /\\lib\\/gi;
}
const srcPathToReplace = path.sep + "src" + path.sep;
for (const key in entry) {
let entryPath = entry[key];
if (entryPath.indexOf("bundle-entries") === -1) {
entryPath = entryPath.replace(libSearchRegexp, srcPathToReplace).slice(0, -3) + ".ts";
} else {
// replace paths and extensions in bundle file
let bundleContent = fs.readFileSync(entryPath).toString();
bundleContent = bundleContent.replace(libSearchRegexp, srcPathToReplace).replace(/\.js/gi, ".ts");
fs.writeFileSync(entryPath, bundleContent);
}
newEntry[key] = entryPath;
}
return newEntry;
}
module.exports = createConfig();