Last active
January 31, 2017 10:37
-
-
Save vitallium/b51a057b1c6d1eb6d0fdba7f690527d7 to your computer and use it in GitHub Desktop.
TS + WebPack2
This file contains hidden or 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
import * as React from "react"; | |
import * as ReactDOM from "react-dom"; | |
import { browserHistory, IndexRedirect, IndexRoute, Route, Router } from "react-router"; | |
import { App } from "./src/Components"; | |
import * as CommonActionCreators from "./src/ActionCreators"; | |
ReactDOM.render(( | |
<Router history={browserHistory}> | |
</Router> | |
), document.getElementById("app")); |
This file contains hidden or 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
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es5", | |
"module": "es2015", | |
"moduleResolution": "node", | |
"declaration": false, | |
"noImplicitAny": false, | |
"removeComments": true, | |
"experimentalDecorators": true, | |
"emitDecoratorMetadata": true, | |
"isolatedModules": false, | |
"noLib": false, | |
"preserveConstEnums": true, | |
"jsx": "react", | |
"sourceMap": true, | |
"importHelpers": true, | |
"lib": [ "es6", "dom" ] | |
}, | |
"awesomeTypescriptLoaderOptions": { | |
"forkChecker": true | |
}, | |
"filesGlob": [ | |
"front/**/*.ts", | |
"front/**/*.tsx" | |
], | |
"exclude": [ | |
"node_modules" | |
] | |
} |
This file contains hidden or 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
import "@blueprintjs/core"; | |
import "axios"; | |
import "class-transformer"; | |
import "d3"; | |
import "fbemitter"; | |
import "flux"; | |
import "lodash-es"; | |
import "moment"; | |
import "react"; | |
import "react-dom"; | |
import "react-proxy"; | |
import "react-router"; | |
import "reflect-metadata"; | |
import "tslib"; |
This file contains hidden or 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
const path = require('path'); | |
const webpack = require('webpack'); | |
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
const nodeEnv = process.env.NODE_ENV || 'development'; | |
const extractSass = new ExtractTextPlugin({ | |
filename: '[name].[contenthash].css', | |
disable: nodeEnv === 'development' | |
}); | |
module.exports = { | |
context: path.resolve(__dirname), | |
entry: { | |
app: './Main.tsx', | |
vendor: './Vendor.ts', | |
}, | |
output: { | |
filename: '[name].[hash].bundle.js', | |
chunkFilename: '[id].[hash].chunk.js', | |
path: path.join(__dirname, '../public/webpack'), | |
publicPath: '/', | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.ts(x?)$/, | |
exclude: [/node_modules/], | |
use: [ | |
{ | |
loader: 'react-hot-loader/webpack', | |
}, | |
{ | |
loader: 'awesome-typescript-loader', | |
}, | |
], | |
}, | |
{ | |
test: /\.scss$/, | |
loader: extractSass.extract({ | |
loader: [{ | |
loader: 'css-loader', | |
}, { | |
loader: 'sass-loader', | |
}], | |
fallbackLoader: 'style-loader', | |
}), | |
}, | |
], | |
}, | |
resolve: { | |
modules: [ | |
'node_modules', | |
path.resolve(__dirname), | |
], | |
descriptionFiles: ['package.json'], | |
extensions: ['.ts', '.tsx', '.js', '.jsx'], | |
moduleExtensions: ['-loader'] | |
}, | |
plugins: [ | |
new webpack.NoEmitOnErrorsPlugin(), | |
new webpack.optimize.CommonsChunkPlugin({ | |
name: ['app', 'vendor'] | |
}), | |
new webpack.DefinePlugin({ | |
'process.env': { NODE_ENV: JSON.stringify(nodeEnv) } | |
}), | |
new webpack.NamedModulesPlugin(), | |
extractSass, | |
], | |
}; |
This file contains hidden or 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
const webpack = require('webpack'); | |
const webpackMerge = require('webpack-merge'); | |
const DashboardPlugin = require('webpack-dashboard/plugin'); | |
const Visualizer = require('webpack-visualizer-plugin'); | |
const path = require('path'); | |
let commonConfig = require('./webpack.config.js'); | |
let config = { | |
entry: { | |
app: [ | |
'react-hot-loader/patch', | |
'./Main.tsx', | |
], | |
vendor: './Vendor.ts', | |
}, | |
output: { | |
filename: '[name].bundle.js', | |
publicPath: 'http://localhost:8080/', | |
}, | |
devtool: 'cheap-eval-source-map', | |
devServer: { | |
contentBase: path.resolve(__dirname, '../public/webpack'), | |
historyApiFallback: true, | |
port: 8080, | |
compress: false, | |
hot: true, | |
headers: { 'Access-Control-Allow-Origin': '*' }, | |
stats: { | |
assets: true, | |
children: false, | |
chunks: false, | |
hash: false, | |
modules: false, | |
publicPath: false, | |
timings: true, | |
version: false, | |
warnings: true, | |
colors: true, | |
}, | |
}, | |
plugins: [ | |
new webpack.HotModuleReplacementPlugin(), | |
new DashboardPlugin(), | |
new Visualizer(), | |
], | |
performance: { | |
hints: false, | |
}, | |
}; | |
module.exports = webpackMerge.strategy({ | |
entry: 'replace', | |
})(commonConfig, config); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment