Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2 from jwanner83/add-typescript-support
Browse files Browse the repository at this point in the history
Add typescript support
  • Loading branch information
faragos authored Feb 18, 2021
2 parents dabf0d7 + b37b4f6 commit 9742401
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 11 deletions.
8 changes: 8 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parserOptions": {
"ecmaVersion": 2017
},
"env": {
"es6": true
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
"webpack-dev-server": "3.2.1",
"webpack-inject-plugin": "^1.5.4",
"eslint": "^7.3.1",
"eslint-loader": "^4.0.2"
"eslint-loader": "^4.0.2",
"typescript": "^4.1.5",
"ts-loader": "^8.0.17"
},
"devDependencies": {
"webpack-hot-middleware": "^2.25.0"
Expand Down
6 changes: 3 additions & 3 deletions src/footer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var parameters = require('cwd/.webpack/parameters.json')
var main = require('mainFn')
const parameters = require('cwd/.webpack/parameters.json')
const main = require('mainFn')

parameters.forEach((entry) => {
parameters.forEach(entry => {
console.log(entry)
main.default(JSON.parse(entry.content))
})
10 changes: 5 additions & 5 deletions start.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
let bootstrapper = require('@clavis/lfr-js-portlet-bootstrapper')
var fs = require('fs')
const bootstrapper = require('@clavis/lfr-js-portlet-bootstrapper')
const fs = require('fs')

module.exports = async function (configPath, basePath) {
await bootstrapper(configPath, basePath)

console.info('Starting Webpack Config')

let config = getConfig(configPath, basePath)

const config = getConfig(configPath, basePath)
const sourcesPath = basePath + config.sources.js

if (!fs.existsSync(sourcesPath)) {
Expand All @@ -25,6 +24,7 @@ module.exports = async function (configPath, basePath) {
}))
webpackConfig.entry.push(process.cwd() + config.sources.js)
webpackConfig.resolve.alias.mainFn = sourcesPath

const options = {
contentBase: sourcesPath + '../',
hot: true,
Expand All @@ -50,7 +50,7 @@ function getConfig (configPath, basePath) {
configPath = 'liferay.portlet.config.js'
}

let fullConfigPath = basePath + '/' + configPath
const fullConfigPath = basePath + '/' + configPath

let finalConfig
const defaultConfig = require(__dirname + '/' + configPath)
Expand Down
5 changes: 5 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"allowJs": true
}
}
12 changes: 10 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
},
{
enforce: 'pre',
test: /\.(js|vue)$/,
test: /\.(ts|js|vue)$/,
loader: 'eslint-loader',
exclude: /node_modules/
},
Expand All @@ -36,6 +36,14 @@ module.exports = {
exclude: /node_modules/,
use: 'babel-loader'
},
{
test: /\.ts?$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
appendTsSuffixTo: [/\.vue$/]
}
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
Expand Down Expand Up @@ -68,7 +76,7 @@ module.exports = {
]
},
resolve: {
extensions: ['.js', '.vue'],
extensions: ['.js', '.vue', '.ts'],
alias: {
cwd: process.cwd(),
}
Expand Down

0 comments on commit 9742401

Please sign in to comment.