Codificando
vcavalcante@lambda3.com.br @vcavalcante
2015
2016
2017
Victor Cavalcante @vcavalcante
Sai o Bower
Entra o NPM
Para gerenciar dependências
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
Text
{
"name": "demo1._1",
"private": true,
"dependencies": {
"jquery": "3.1.1",
"jquery-validation-unobtrusive":"3.2.6",
"lodash": "4.17.4",
"bootstrap": "3.3.7"
}
}
{
"name": "demo1",
"version": "1.0.0",
"description": "Demo1 do codificando",
"author": "",
"license": "ISC",
"dependencies": {
"jquery": "3.1.1",
"jquery-validation-unobtrusive":"3.2.6",
"lodash": "4.17.4",
"bootstrap": "3.3.7"
}
}
Victor Cavalcante @vcavalcante
Agora vamos do Gulp/Grunt para o ...
Victor Cavalcante @vcavalcante
Antes a responsabilidade de tudo que não fosse gerenciamento de pacotes era do Gulp/Grunt
Victor Cavalcante @vcavalcante
Empacotamento de código é com o
Execução de tasks é com o NPM
webpack
Victor Cavalcante @vcavalcante
{
"name": "asp.net",
"private": true,
"version": "1.0.0",
"scripts": {
"build": "rimraf ./wwwroot/dist && webpack --bail --progress --profile",
"serve:webpack": "webpack-dev-server --history-api-fallback --inline --progress --hot",
"serve:dotnet": "dotnet watch run",
"test": "karma start",
"test:auto": "karma start --auto-watch --no-single-run",
"test:dotnet": "npm-run-all test:u test:i test:a",
"test:a": "dotnet test ..\\..\\test\\Tests.Acceptance",
"test:i": "dotnet test ..\\..\\test\\Tests.Integration",
"test:u": "dotnet test ..\\..\\test\\Tests.Unit",
"start": "npm-run-all --parallel serve:*",
"db:create": "node migrate.js",
"db:migrate": "node migrate.js",
"db:seed": "node migrate.js",
"db:csv": "node migrate.js",
"db": "npm-run-all db:create db:migrate"
}
}
Victor Cavalcante @vcavalcante
{
"name": "asp.net",
"private": true,
"version": "1.0.0",
"scripts": {
"build": "rimraf ./wwwroot/dist && webpack --bail --progress --profile"
}
}
Victor Cavalcante @vcavalcante
{
"name": "asp.net",
"private": true,
"version": "1.0.0",
"scripts": {
"task1":"echo task1",
"task2":"echo task2",
"build": "npm run task1 && npm task2"
}
}
Victor Cavalcante @vcavalcante
// scripts/favicon.js
var favicons = require('favicons');
var path = require('path');
favicons({
source: path.resolve('../assets/images/logo.png'),
dest: path.resolve('../dist/'),
});
"devDependencies": {
"favicons": "latest",
},
"scripts": {
"build:favicon": "node scripts/favicon.js",
}
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
npm install webpack -g
//primeiro.js
document.write("Teste!");
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script src="bundle.js"></script>
</body>
</html>
webpack primeiro.js bundle.js
//Conteudo.js
module.exports = "Olá estou sendo exportado";
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script src="bundle.js"></script>
</body>
</html>
webpack primeiro.js bundle.js
//primeiro.js
document.write(require("./conteudo.js"));
npm install css-loader style-loader
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script src="bundle.js"></script>
</body>
</html>
webpack primeiro.js bundle.js
//primeiro.js
require("!style-loader!css-loader!./estilo.css");
document.write(require("./conteudo.js"));
//estilo.css
body{ background-color:red; }
//Conteudo.js
module.exports = "Olá estou sendo exportado";
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script src="bundle.js"></script>
</body>
</html>
webpack primeiro.js bundle.js
//primeiro.js
document.write(require("./conteudo.js"));
module.exports = {
entry: "./entry.js",
output: {
path: __dirname,
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.css$/, loader: "style!css" }
]
}
};
Victor Cavalcante @vcavalcante
Victor Cavalcante @vcavalcante
victor@cavalcante.net