Created
September 15, 2017 06:16
-
-
Save anonymous/7bd15c1eb19d51d7a435299ec63d9550 to your computer and use it in GitHub Desktop.
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
{ | |
"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" | |
} | |
} |
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
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" |
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
{ | |
"compilerOptions": { | |
"noImplicitAny": false, | |
"noEmitOnError": true, | |
"removeComments": false, | |
"sourceMap": true, | |
"target": "es6", | |
"module": "commonjs", | |
"moduleResolution": "node" | |
}, | |
"exclude": [ | |
"node_modules", | |
"wwwroot" | |
] | |
} |
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
var path = require('path'); | |
module.exports = { | |
entry: { | |
site: ['./Scripts/app.ts'] | |
}, | |
output: { | |
filename: 'bundle.js', | |
path: path.resolve(__dirname, 'wwwroot/dist/') | |
}, | |
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
updated webpack.config
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"]
}
};