mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
making build much much faster
This commit is contained in:
@@ -12,7 +12,7 @@ interface TodoListProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const TodoList = (props: TodoListProps) => {
|
export const TodoList = (props: TodoListProps) => {
|
||||||
const { filter, todos, complete, remove, edit } = this.props;
|
const { filter, todos, complete, remove, edit } = props;
|
||||||
const filteredTodos = Object.keys(todos).filter(id => {
|
const filteredTodos = Object.keys(todos).filter(id => {
|
||||||
return filter === 'all' || (filter === 'completed' && todos[id].completed) || (filter === 'active' && !todos[id].completed);
|
return filter === 'all' || (filter === 'completed' && todos[id].completed) || (filter === 'active' && !todos[id].completed);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// @ts-check
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
||||||
@@ -12,10 +14,9 @@ const entries = {
|
|||||||
playground: './playground/src/index'
|
playground: './playground/src/index'
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Object.keys(entries).map(entryPoint => {
|
module.exports = function() {
|
||||||
const entryRequest = entries[entryPoint];
|
|
||||||
return {
|
return {
|
||||||
entry: { [entryPoint]: entryRequest },
|
entry: entries,
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
@@ -31,22 +32,24 @@ module.exports = Object.keys(entries).map(entryPoint => {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new HtmlWebpackPlugin({
|
...Object.keys(entries).map(entry => {
|
||||||
template: path.join(__dirname, `${entryPoint}/index.html`),
|
return new HtmlWebpackPlugin({
|
||||||
filename: '../index.html'
|
template: path.join(__dirname, entry, 'index.html'),
|
||||||
|
filename: `${entry}/index.html`,
|
||||||
|
chunks: [entry]
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
new ForkTsCheckerWebpackPlugin({
|
new ForkTsCheckerWebpackPlugin({
|
||||||
silent: true,
|
silent: true,
|
||||||
async: false,
|
async: false
|
||||||
useTypescriptIncrementalApi: true
|
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.tsx', '.ts', '.js']
|
extensions: ['.tsx', '.ts', '.js']
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
filename: '[name].js',
|
filename: '[name]/dist/[name].js',
|
||||||
path: path.resolve(__dirname, entryPoint, 'dist')
|
path: path.resolve(__dirname)
|
||||||
},
|
},
|
||||||
devServer: {
|
devServer: {
|
||||||
contentBase: path.resolve(__dirname),
|
contentBase: path.resolve(__dirname),
|
||||||
@@ -60,4 +63,4 @@ module.exports = Object.keys(entries).map(entryPoint => {
|
|||||||
mode: 'development',
|
mode: 'development',
|
||||||
devtool: 'eval'
|
devtool: 'eval'
|
||||||
};
|
};
|
||||||
});
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user