M2 MIAGE NDTP
Oussama Nehouchi
Andy Rabadan
// Concatenate JS Files
gulp.task('scripts', function() {
return gulp.src('src/js/*.js')
.pipe(concat('main.js'))
.pipe(gulp.dest('dist/js'));
});
// Build CSS from SASS
gulp.task('sass', function() {
return sass('src/scss/style.scss', {style: 'compressed'})
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('dist/css'));
});
gulp.task('default', ['scripts', 'sass']);
Ligne de commande
> webpack <entry> [<entry>] <output>
Fichier de configuration webpack.config.js
module.exports = {
// configuration
};
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractCSS = new ExtractTextPlugin('bundle.css');
var path = require('path');
var src = path.join(__dirname, 'src');
module.exports = {
context: src,
entry: {
app: ['./css/sky.css', './css/theme.css', './css/fonts.css', './app.js']
},
output: {
path: "dist",
filename: "bundle.js",
publicPath: "/"
},
module: {
loaders: [
{
test: /\.css$/,
loader: extractCSS.extract("css")
}
]
},
plugins: [
extractCSS,
new webpack.optimize.UglifyJsPlugin({
comment: false
}),
new webpack.HotModuleReplacementPlugin()
]
};
module.exports = "It works !";
var Reveal = require("reveal.js");
var chaine = require("./chaine.js");
require("reveal.js/css/reveal.css");
Reveal.initialize({...});
console.log(chaine);
chaine.js
app.js
reveal.js
sky.css
theme.css
fonts.css
bundle.css
bundle.js
reveal.css
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="bundle.css">
<title>WebPack</title>
</head>
<body class="theme-font-montserrat theme-color-blue-yellow">
<div class="reveal">
...
</div>
<script src="bundle.js"></script>
</body>
</html>
> npm install --save reveal
var Reveal = require("reveal.js");
Reveal.initialize({
...
});
devServer: {
contentBase: src,
hot: true,
inline: true,
progress: true,
colors: true
}
> npm install -g webpack-dev-server
webpack.config.js