Skip to content

Instantly share code, notes, and snippets.

@Kayli
Forked from anonymous/package.json
Created September 15, 2017 06:44
Show Gist options
  • Save Kayli/18d35aa15992a18f673a233049a46b53 to your computer and use it in GitHub Desktop.
Save Kayli/18d35aa15992a18f673a233049a46b53 to your computer and use it in GitHub Desktop.
{
"name": "WebpackExample01",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/jquery": "^3.2.12",
"@types/knockout": "^3.4.45",
"jquery": "^3.2.1",
"knockout": "^3.4.2",
"ts-loader": "^2.3.7",
"typescript": "^2.5.2",
"webpack": "^3.5.6"
}
}
execute following commands in a terminal:
npm init -y
npm install npm@latest
npm install webpack --save-dev
npm install --save-dev typescript ts-loader
npm install --save-dev jquery @types/jquery
add pre-build event in visual studio project properties:
npm run build
add "build" task to "scripts" section of package.json:
"build": "webpack"
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es6",
"module": "commonjs",
"moduleResolution": "node"
},
"exclude": [
"node_modules",
"wwwroot"
]
}
var path = require('path');
var webpack = require("webpack");
module.exports = {
entry: {
app: ['./Scripts/app.ts'],
vendor: ["jquery", "knockout"]
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'wwwroot/dist/')
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({ name: "vendor", filename: "vendor.bundle.js", minChunks: Infinity })
],
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/
}
]
},
resolve: {
extensions: [".tsx", ".ts", ".js"]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment