본문 바로가기

엉터리 개발 이야기

Gridster 번들링

반응형

webpack 설정...


npm i --save dsmorse-gridster jquery



index.js

import $ from 'jquery';
import 'dsmorse-gridster/dist/jquery.dsmorse-gridster';
import 'dsmorse-gridster/dist/jquery.dsmorse-gridster.min.css';
import './css/demo.css';
window.$ = $;


main.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Babel Demo</title>
<script type="text/javascript" src="dist/main.js"></script>
<!--<link rel="stylesheet" type="text/css" href="src/css/demo.css">-->

</head>
<body>
<div class="gridster">
<ul></ul>
</div>
</body>
<script type="text/javascript" id="code">
var gridster;

$(function () {

gridster = $(".gridster > ul").gridster({
widget_margins: [5, 5],
widget_base_dimensions: [100, 55]
}).data('gridster');

var widgets = [
['<li>0</li>', 1, 2],
['<li>1</li>', 3, 2],
['<li>2</li>', 3, 2],
];

$.each(widgets, function (i, widget) {
gridster.add_widget.apply(gridster, widget)
});

});
</script>
</html>


demo.css

/*! gridster.js - v0.6.10 - 2015-05-31
* https://dsmorse.github.io/gridster.js/
* Copyright (c) 2015 ducksboard; Licensed MIT */
body {
background: #26941f;
font-size: 16px;
font-family: 'Helvetica Neue', Arial, sans-serif;
color: #ffffff;
margin: 0;
}
h1,
h2,
h3,
p {
margin: 10px;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
.demo {
margin: 3em 0;
padding: 7.5em 0 5.5em;
background: #26941f;
}
.demo:hover .gridster {
margin: 0 auto;
opacity: .8;
-webkit-transition: opacity .6s;
-moz-transition: opacity .6s;
-o-transition: opacity .6s;
-ms-transition: opacity .6s;
transition: opacity .6s;
}
.content {
color: white;
}
.gridster .gs-w {
background: #61A9CF;
cursor: pointer;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
.gridster .player {
-webkit-box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3);
box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3);
background: #BBB;
}
.gridster .gs-w.try {
background-repeat: no-repeat;
background-position: 37px -169px;
}
.gridster .preview-holder {
border: none !important;
border-radius: 0 !important;
background: red !important;
}
.gridster ul {
background-color: #EFEFEF;
}
.gridster li {
font-size: 1em;
font-weight: bold;
text-align: center;
line-height: 100%;
}
ul {
list-style-type: none;
}
li {
list-style: none;
font-weight: bold;
}
.gridster-box {
position: relative;
width: 100%;
height: 100%;
}
.controls {
margin-bottom: 20px;
}
/*# sourceMappingURL=demos/assets/css/demo.css.map */


webpack.config.js

const path = require('path');

module.exports = {
//entry: './src/js/entry.js',
// 컴파일 + 번들링된 js 파일이 저장될 경로와 이름 지정
// output: {
// path: path.resolve(__dirname, 'dist/js'),
// filename: 'bundle.js'
// },
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
devtool: 'source-map',
// https://webpack.js.org/concepts/mode/#mode-development
mode: 'development'
};




반응형