Skip to content

Instantly share code, notes, and snippets.

@magichim magichim/package.json
Last active Dec 3, 2017

Embed
What would you like to do?
Webpack, Typescript base configuration setting.
{
"name": "songwon-me",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "test",
"serve": "webpack-dev-server --config=webpack.config.js --hot --inline --progress --watch --open",
"build": "rm -rf dist && webpack"
},
"author": "",
"license": "ISC",
"devDependencies": {
"awesome-typescript-loader": "^3.4.1",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"source-map-loader": "^0.2.3",
"ts-loader": "^3.2.0",
"typescript": "^2.6.1",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.5.1"
}
}
{
"compilerOptions": {
"outDir": "./dist/",
"noImplicitAny": true,
"module": "es6",
"target": "es5",
"allowJs": true,
"sourceMap": true
}
}
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
context: path.resolve("./src"),
entry: {
app: ['babel-polyfill', './js/index.js', './ts/index.ts'],
vendor: './vendor/vendor.js'
},
output: {
filename: `[name].${+new Date}.js`,
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
},
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
use: {
loader: 'ts-loader'
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: 'index.html'
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
filename: '[name].bundle.js'
}),
new webpack.optimize.UglifyJsPlugin({
uglifyOptions: {
compress: true,
warnings: true
}
})
],
devServer: {
contentBase: path.join(__dirname, "dist/"),
compress: true,
port: 4000,
hot: true
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.