-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
7,018 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as webpack from 'webpack' | ||
import { makeConfig } from './webpack.config' | ||
|
||
const conf = makeConfig(true) | ||
const compiler = webpack(conf) | ||
|
||
compiler.run((err, stats) => { | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "webpack5", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"webpack": "^5.0.0-beta.17", | ||
"webpack-dev-server": "^3.11.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as webpack from 'webpack' | ||
import { makeConfig } from './webpack.config' | ||
import * as http from 'http' | ||
import { join } from 'path' | ||
const staticServer = require('node-static').Server | ||
|
||
const compiler = webpack(makeConfig(true)) | ||
|
||
compiler.watch({ poll: 100 }, (err, stats) => { | ||
console.log(stats.toJson('minimal' as any)) | ||
}) | ||
|
||
const file = new staticServer(join(__dirname + '/build')) | ||
console.log('Static HTTP server is listenting on', process.env.PORT) | ||
http.createServer((request, response) => { | ||
request.addListener('end', function () { | ||
file.serve(request, response); | ||
}).resume(); | ||
}).listen(process.env.PORT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as webpack from 'webpack' | ||
import config from './webpack.config' | ||
const WebpackDevServer = require('webpack-dev-server') | ||
|
||
new WebpackDevServer(webpack(config), { | ||
disableHostCheck: true, | ||
hot: true, | ||
stats: { colors: true }, | ||
port: process.env.PORT, | ||
historyApiFallback: { | ||
index: 'index.html', | ||
} | ||
}) | ||
.listen(process.env.PORT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import * as webpack from 'webpack' | ||
import * as path from 'path' | ||
import * as fs from 'fs' | ||
const HtmlWebpackPlugin = require('html-webpack-plugin') | ||
const CleanWebpackPlugin = require('clean-webpack-plugin') | ||
import { LoaderOptions } from '../src/lp-loader' | ||
export const makeConfig = (isProduction = false) => { | ||
const isDevelopment = !isProduction | ||
|
||
process.env.LP_DEBUG = 'true' | ||
|
||
const appEntry = [ | ||
path.join(__dirname, '../app/app') | ||
] | ||
|
||
const buildDir = path.join(__dirname, 'build') | ||
const tsLoaderOptions = { | ||
compilerOptions: { | ||
module: "esnext", | ||
declaration: false, | ||
moduleResolution: 'node' | ||
} | ||
} | ||
const lpTsIndexFiles = /dict(\\|\/)index\.ts/ | ||
const lpLoader = path.join(__dirname, '../src/lp-loader') | ||
const config: webpack.Configuration = { | ||
//mode: 'development', | ||
entry: { | ||
app: appEntry | ||
}, | ||
output: { | ||
path: buildDir, | ||
filename: '[name]-[hash].js', | ||
chunkFilename: '[name]-[chunkhash].js', | ||
publicPath: '/' | ||
}, | ||
plugins: [ | ||
//new (webpack as any).NamedModulesPlugin(), | ||
...isDevelopment ? [ | ||
new webpack.HotModuleReplacementPlugin() | ||
] : [ | ||
new CleanWebpackPlugin([buildDir], { | ||
root: path.resolve(__dirname, '../..') | ||
}) | ||
], | ||
new HtmlWebpackPlugin({ | ||
title: 'LP-Loader ' + (isDevelopment ? 'Dev' : 'Build'), | ||
filename: 'index.html' | ||
}) | ||
], | ||
module: { | ||
rules: [ | ||
{ | ||
test: lpTsIndexFiles, loaders: [ | ||
{} | ||
{ | ||
loader: lpLoader, query: { | ||
name: 'language.pack', | ||
include: /(\\|\/)\w{2}\.ts/ | ||
} as LoaderOptions | ||
}, | ||
//{ loader: 'ts-loader', query: tsLoaderOptions } as any | ||
//{ loader: path.join(__dirname, 'ts-simple-loader'), query: tsLoaderOptions } as any | ||
] | ||
}, | ||
{ | ||
test: /\.ts$/, | ||
loader: 'ts-loader', | ||
//iexclude: [lpTsIndexFiles], | ||
query: tsLoaderOptions | ||
}, | ||
{ test: /\.css$/, loader: 'style!css' }, | ||
] | ||
}, | ||
devtool: isDevelopment ? 'eval' : 'inline-source-map', | ||
resolve: { | ||
extensions: ['.ts', '.js'], | ||
alias: { | ||
//'lp': path.resolve(__dirname, '../../lib/lp-loader.ts'), | ||
} | ||
}, | ||
resolveLoader: { | ||
extensions: ['.ts', '.js'], | ||
alias: { | ||
//'ts': 'awesome-typescript-loader' | ||
//'ts': 'ts-loader' | ||
}, | ||
modules: [ | ||
path.resolve(__dirname, 'node_modules'), | ||
path.resolve(__dirname, '../node_modules'), | ||
path.resolve(__dirname, '../src'), | ||
] | ||
} | ||
} | ||
|
||
return config | ||
} | ||
|
||
export default makeConfig() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as webpack from 'webpack' | ||
import { makeConfig } from './webpack.config' | ||
|
||
const compiler = webpack(makeConfig(true)) | ||
|
||
compiler.run((err, stats) => { | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "webpack3", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@types/webpack": "^3.0.10", | ||
"clean-webpack-plugin": "^0.1.16", | ||
"html-webpack-plugin": "^2.30.1", | ||
"ts-loader": "^2.3.4", | ||
"webpack": "^3.5.5", | ||
"webpack-dev-server": "^2.7.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as webpack from 'webpack' | ||
import { makeConfig } from './webpack.config' | ||
import * as http from 'http' | ||
import { join } from 'path' | ||
const staticServer = require('node-static').Server | ||
|
||
const compiler = webpack(makeConfig(true)) | ||
|
||
compiler.watch({ poll: 100 }, (err, stats) => { | ||
console.log(stats.toJson('minimal' as any)) | ||
}) | ||
|
||
const file = new staticServer(join(__dirname + '/build')) | ||
console.log('Static HTTP server is listenting on', process.env.PORT) | ||
http.createServer((request, response) => { | ||
request.addListener('end', function () { | ||
file.serve(request, response); | ||
}).resume(); | ||
}).listen(process.env.PORT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as webpack from 'webpack' | ||
import config from './webpack.config' | ||
const WebpackDevServer = require('webpack-dev-server') | ||
|
||
new WebpackDevServer(webpack(config), { | ||
disableHostCheck: true, | ||
hot: true, | ||
stats: { colors: true }, | ||
port: process.env.PORT, | ||
historyApiFallback: { | ||
index: 'index.html', | ||
} | ||
}) | ||
.listen(process.env.PORT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import * as webpack from 'webpack' | ||
import * as path from 'path' | ||
import * as fs from 'fs' | ||
const HtmlWebpackPlugin = require('html-webpack-plugin') | ||
const CleanWebpackPlugin = require('clean-webpack-plugin') | ||
|
||
export const makeConfig = (isProduction = false) => { | ||
const isDevelopment = !isProduction | ||
|
||
const appEntry = [ | ||
path.join(__dirname, '../app/app') | ||
] | ||
|
||
isDevelopment && appEntry.push( | ||
//'webpack-dev-server/client?http://localhost:' + process.env.PORT, | ||
//'webpack/hot/only-dev-server' | ||
) | ||
|
||
const buildDir = path.join(__dirname, 'build') | ||
const tsLoaderOptions = { | ||
compilerOptions: { | ||
module: "esnext", | ||
declaration: false, | ||
moduleResolution: 'node' | ||
} | ||
} | ||
const lpTsIndexFiles = /dict(\\|\/)index.ts/ | ||
const config: webpack.Configuration = { | ||
entry: { | ||
app: appEntry | ||
}, | ||
output: { | ||
path: buildDir, | ||
filename: '[name]-[hash].js', | ||
//-[chunkhash] | ||
chunkFilename: '[name]-[chunkhash].js', | ||
publicPath: '/' | ||
}, | ||
plugins: [ | ||
new CleanWebpackPlugin([buildDir], { | ||
root: path.resolve(__dirname, '../..') | ||
}), | ||
new (webpack as any).NamedModulesPlugin(), | ||
new webpack.HotModuleReplacementPlugin(), | ||
new HtmlWebpackPlugin({ | ||
title: 'LP-Loader ' + (isDevelopment ? 'Dev' : 'Build'), | ||
filename: 'index.html' | ||
}) | ||
], | ||
module: { | ||
loaders: [ | ||
//{ test: /dict(\\|\/)index.js/, loader: 'lp-loader' }, | ||
{ | ||
test: lpTsIndexFiles, loaders: [ | ||
{ loader: path.join(__dirname, '../src/lp-loader'), query: { name: 'language.pack' } } as any, | ||
{ loader: 'ts-loader', query: tsLoaderOptions } as any | ||
] | ||
}, | ||
{ | ||
test: /\.ts$/, | ||
loader: 'ts-loader', | ||
exclude: [lpTsIndexFiles], | ||
query: tsLoaderOptions | ||
}, | ||
{ test: /\.css$/, loader: 'style!css' }, | ||
] | ||
}, | ||
devtool: 'eval', | ||
resolve: { | ||
extensions: ['.ts', '.js'], | ||
alias: { | ||
//'lp': path.resolve(__dirname, '../../lib/lp-loader.ts'), | ||
} | ||
}, | ||
resolveLoader: <any>{ | ||
extensions: ['.ts', '.js'], | ||
alias: { | ||
//'ts': 'awesome-typescript-loader' | ||
//'ts': 'ts-loader' | ||
}, | ||
modules: [ | ||
path.resolve(__dirname, 'node_modules'), | ||
path.resolve(__dirname, '../node_modules'), | ||
path.resolve(__dirname, '../src'), | ||
] | ||
} | ||
} | ||
|
||
return config | ||
} | ||
|
||
export default makeConfig() |
Oops, something went wrong.