ソースを参照

add example webpack config

Robin Herbots 8 年 前
コミット
bacb40cf7d
6 ファイル変更170 行追加71 行削除
  1. 1 0
      CHANGELOG.md
  2. 1 10
      Gruntfile.js
  3. 12 0
      app.js
  4. 15 0
      index.html
  5. 74 61
      package.json
  6. 67 0
      webpack.config.js

+ 1 - 0
CHANGELOG.md

@@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
 
 ## [UNRELEASED]
 ### Added
+- add example webpack setup (thx to Kevin Suen)
 - build-in regex support without extension
 
 ### Updates

+ 1 - 10
Gruntfile.js

@@ -156,15 +156,6 @@ module.exports = function (grunt) {
 					showTasks: ['user']
 				}
 			}
-		},
-		browserify: {
-			dist: {
-				dest: 'build/browserify.bundle.js',
-				src: [],
-				options: {
-					require: ["./dist/inputmask/inputmask.js"]
-				}
-			}
 		}
 	});
 
@@ -174,7 +165,7 @@ module.exports = function (grunt) {
 	grunt.registerTask('publish:patch', ['clean', 'bump:patch', 'uglify', 'shell:gitcommitchanges', 'release', 'nugetpack', 'nugetpush']);
 	grunt.registerTask('publish:minor', ['clean', 'bump:minor', 'uglify', 'shell:gitcommitchanges', 'release', 'nugetpack', 'nugetpush']);
 	grunt.registerTask('publish:major', ['clean', 'bump:major', 'uglify', 'shell:gitcommitchanges', 'release', 'nugetpack', 'nugetpush']);
-	grunt.registerTask('validate', ['eslint', 'browserify', 'karma']);
+	grunt.registerTask('validate', ['eslint', 'karma']);
 	grunt.registerTask('build', ['bump:prerelease', 'clean', 'uglify']);
 	grunt.registerTask('default', ["availabletasks"]);
 };

+ 12 - 0
app.js

@@ -0,0 +1,12 @@
+import "./js/inputmask.date.extensions"
+import "./js/inputmask.extensions"
+import "./js/inputmask.numeric.extensions"
+import "./js/inputmask.phone.extensions"
+import "./js/inputmask.regex.extensions"
+
+import im from "./js/inputmask.js"
+
+//just for testing
+window.Inputmask = im;
+
+

+ 15 - 0
index.html

@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+</head>
+<body>
+<input id="test1" name="test1"/>
+<br/>
+<script type="text/javascript" src="http://localhost:8080/build/bundle.js" charset="utf-8"></script>
+<script>
+	Inputmask("currency").mask("test1");
+</script>
+</body>
+</html>

+ 74 - 61
package.json

@@ -1,63 +1,76 @@
 {
-	"name": "jquery.inputmask",
-	"version": "3.3.5-213",
-	"description": "jquery.inputmask is a jquery plugin which create an input mask.",
-	"main": "dist/jquery.inputmask.bundle.js",
-	"files": [
-		"dist/",
-		"css/"
-	],
-	"scripts": {
-		"test": "grunt validate"
-	},
-	"repository": {
-		"type": "git",
-		"url": "https://github.com/RobinHerbots/jquery.inputmask.git"
-	},
-	"keywords": [
-		"form",
-		"input",
-		"inputmask",
-		"jquery",
-		"jquery-plugin",
-		"mask",
-		"plugins"
-	],
-	"author": {
-		"name": "Robin Herbots",
-		"url": "https://github.com/RobinHerbots"
-	},
-	"license": "MIT",
-	"bugs": {
-		"url": "https://github.com/RobinHerbots/jquery.inputmask/issues"
-	},
-	"homepage": "https://github.com/RobinHerbots/jquery.inputmask",
-	"devDependencies": {
-		"browserify": "^13.0.1",
-		"browserify-shim": "^3.8.11",
-		"grunt": "^1.0.1",
-		"grunt-available-tasks": "^0.6.0",
-		"grunt-browserify": "^5.0.0",
-		"grunt-bump": "^0.8.0",
-		"grunt-cli": "^1.2.0",
-		"grunt-contrib-clean": "^1.0.0",
-		"grunt-contrib-uglify": "^1.0.1",
-		"grunt-eslint": "^19.0.0",
-		"grunt-karma": "^2.0.0",
-		"grunt-nuget": "^0.1.5",
-		"grunt-release": "^0.14.0",
-		"grunt-shell": "^1.1.2",
-		"jqlite": "^0.2.25",
-		"karma": "^1.1.1",
-		"karma-chrome-launcher": "^1.0.1",
-		"karma-firefox-launcher": "^1.0.0",
-		"karma-ie-launcher": "^1.0.0",
-		"karma-phantomjs-launcher": "^1.0.0",
-		"karma-qunit": "^1.1.0",
-		"karma-requirejs": "^1.0.0",
-		"load-grunt-tasks": "^3.2.0",
-		"phantomjs-prebuilt": "^2.1.7",
-		"qunitjs": "^1.23.1",
-		"requirejs": "^2.1.20"
-	}
+  "name": "jquery.inputmask",
+  "version": "3.3.5-213",
+  "description": "jquery.inputmask is a jquery plugin which create an input mask.",
+  "main": "dist/jquery.inputmask.bundle.js",
+  "files": [
+    "dist/",
+    "css/"
+  ],
+  "scripts": {
+    "start": "webpack-dev-server --progress --colors ",
+    "build": "webpack --progress --colors --watch",
+    "test": "grunt validate"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/RobinHerbots/jquery.inputmask.git"
+  },
+  "keywords": [
+    "form",
+    "input",
+    "inputmask",
+    "jquery",
+    "jquery-plugin",
+    "mask",
+    "plugins"
+  ],
+  "author": {
+    "name": "Robin Herbots",
+    "url": "https://github.com/RobinHerbots"
+  },
+  "license": "MIT",
+  "bugs": {
+    "url": "https://github.com/RobinHerbots/jquery.inputmask/issues"
+  },
+  "homepage": "https://github.com/RobinHerbots/jquery.inputmask",
+  "devDependencies": {
+    "babel-core": "^6.0.0",
+    "babel-loader": "^6.2.4",
+    "babel-preset-es2015": "^6.9.0",
+    "babel-preset-stage-0": "^6.5.0",
+    "css-loader": "^0.28.0",
+    "grunt": "^1.0.1",
+    "grunt-available-tasks": "^0.6.0",
+    "grunt-browserify": "^5.0.0",
+    "grunt-bump": "^0.8.0",
+    "grunt-cli": "^1.2.0",
+    "grunt-contrib-clean": "^1.0.0",
+    "grunt-contrib-uglify": "^1.0.1",
+    "grunt-eslint": "^19.0.0",
+    "grunt-karma": "^2.0.0",
+    "grunt-nuget": "^0.1.5",
+    "grunt-release": "^0.14.0",
+    "grunt-shell": "^1.1.2",
+    "jqlite": "^0.2.25",
+    "jquery": "^3.2.1",
+    "karma": "^1.1.1",
+    "karma-chrome-launcher": "^1.0.1",
+    "karma-firefox-launcher": "^1.0.0",
+    "karma-ie-launcher": "^1.0.0",
+    "karma-phantomjs-launcher": "^1.0.0",
+    "karma-qunit": "^1.1.0",
+    "karma-requirejs": "^1.0.0",
+    "load-grunt-tasks": "^3.2.0",
+    "phantomjs": "^2.1.7",
+    "postcss": "^5.0.21",
+    "postcss-cssnext": "^2.6.0",
+    "postcss-loader": "^0.9.1",
+    "qunitjs": "^1.23.1",
+    "requirejs": "^2.1.20",
+    "source-map-loader": "^0.1.5",
+    "style-loader": "^0.16.1",
+    "webpack": "^1.13.1",
+    "webpack-dev-server": "^1.14.1"
+  }
 }

+ 67 - 0
webpack.config.js

@@ -0,0 +1,67 @@
+'use strict';
+
+let webpack = require('webpack');
+let postcss_cssnext = require('postcss-cssnext');
+let path = require('path');
+
+function _path(p) {
+	return path.join(__dirname, p);
+}
+
+module.exports = {
+	entry: "./app.js",
+	output: {
+		path: __dirname,
+		filename: "build/bundle.js"
+	},
+	module: {
+		preLoaders: [
+			{
+				test: /\.js$/,
+				loader:'source-map',
+			},
+		],
+		loaders: [
+			{
+				test: /\.js$/,
+				loader: 'babel',
+				exclude: /(node_modules)/,
+				query: {
+					presets: [
+						'es2015',
+						'stage-0',
+					],
+					passPerPreset: true,
+				},
+			},
+			{
+				test: /\.css$/,
+				loader: 'style!css?importLoaders=1!postcss',
+			},
+		]
+	},
+	postcss: [postcss_cssnext],
+	resolve: {
+		alias: {
+		},
+	},
+	plugins: [
+		new webpack.SourceMapDevToolPlugin(
+			'[file].map', null,
+			'[absolute-resource-path]',
+			'[absolute-resource-path]'
+		),
+	],
+	bail: true,
+	debug: true,
+	devServer: {
+		publicPath: '/',
+		outputPath: _path('build'),
+		stats: {colors: true},
+		host: '0.0.0.0',
+		inline: true,
+		port: '8080',
+		quiet: false,
+		noInfo: false,
+	},
+};