Skip to content

Commit 59a4857

Browse files
authored
Merge pull request #11 from yama-dev/v0.4.0
adjust build settings.
2 parents 21ffb89 + c0fd64a commit 59a4857

File tree

2 files changed

+105
-21
lines changed

2 files changed

+105
-21
lines changed

package.json

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-scroll-effect-module",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "Add effect at scroll.",
55
"keywords": [
66
"scroll",
@@ -17,9 +17,13 @@
1717
"main": "./dist/js-scroll-effect-module.js",
1818
"scripts": {
1919
"start": "npm install && npm run develop",
20-
"develop": "npm-run-all -p build:webpack server",
21-
"server": "browser-sync start --server ./ --directory ./sample --files **/*.css **/*.js **/*.html",
22-
"build:webpack": "webpack --progress --colors --watch"
20+
"develop": "npm-run-all -p build:develop server:develop",
21+
"server:develop": "browser-sync start --server ./ --directory ./sample --files **/*.css **/*.js **/*.html",
22+
"build:develop": "webpack --mode=development --progress --colors --watch",
23+
"production": "npm-run-all -p build:production server:production",
24+
"server:production": "browser-sync start --server ./ --directory ./sample --files **/*.css **/*.js **/*.html",
25+
"build:production": "webpack --mode=production --progress --colors --watch",
26+
"test": "mocha --compilers js:babel-core/register"
2327
},
2428
"repository": {
2529
"type": "git",
@@ -30,16 +34,57 @@
3034
"email": "[email protected]"
3135
},
3236
"devDependencies": {
33-
"babel-cli": "^6.26.0",
34-
"babel-core": "^6.26.0",
35-
"babel-loader": "^7.1.4",
36-
"babel-preset-env": "^1.6.1",
37+
"@babel/cli": "^7.2.3",
38+
"@babel/core": "^7.2.2",
39+
"@babel/plugin-transform-object-assign": "^7.2.0",
40+
"@babel/preset-env": "^7.3.1",
41+
"babel-loader": "^8.0.5",
3742
"browser-sync": "^2.23.6",
43+
"eslint": "^5.12.0",
44+
"eslint-loader": "^2.1.1",
45+
"mocha": "^5.2.0",
3846
"npm-run-all": "^4.1.2",
39-
"webpack": "^4.27.1",
40-
"webpack-cli": "^3.1.2"
47+
"webpack": "^4.28.4",
48+
"webpack-cli": "^3.2.1"
4149
},
4250
"dependencies": {
4351
"@yama-dev/js-dom": "0.0.6"
52+
},
53+
"eslintConfig": {
54+
"env": {
55+
"browser": true,
56+
"commonjs": true,
57+
"es6": true,
58+
"jquery": true,
59+
"node": true
60+
},
61+
"extends": "eslint:recommended",
62+
"parserOptions": {
63+
"ecmaFeatures": {
64+
"jsx": true
65+
},
66+
"ecmaVersion": 2018,
67+
"sourceType": "module"
68+
},
69+
"plugins": [],
70+
"rules": {
71+
"indent": [
72+
"error",
73+
2,
74+
{
75+
"outerIIFEBody": 0
76+
}
77+
],
78+
"quotes": [
79+
"error",
80+
"single"
81+
],
82+
"semi": [
83+
"error",
84+
"always"
85+
],
86+
"no-console": "warn",
87+
"no-unused-vars": "warn"
88+
}
4489
}
4590
}

webpack.config.js

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
1+
const pkg = require('./package.json');
2+
3+
const comment = `JS COUNT MODULE (JavaScript Library)
4+
${pkg.name}
5+
Version ${pkg.version}
6+
Repository ${pkg.repository.url}
7+
Copyright ${pkg.author}
8+
Licensed ${pkg.license}`;
9+
10+
const env = process.env.NODE_ENV;
11+
112
const webpack = require('webpack');
213

14+
const webpackPlugEnv = new webpack.EnvironmentPlugin({
15+
NODE_ENV: 'development',
16+
DEBUG: false,
17+
VERSION: pkg.version
18+
});
19+
20+
const webpackPlugBnr = new webpack.BannerPlugin({
21+
banner: comment,
22+
});
23+
24+
const babelPlugin = [
25+
'@babel/plugin-transform-object-assign'
26+
];
27+
328
const config = {
4-
mode: 'production',
29+
mode: env || 'development',
530
entry: './src/js-scroll-effect-module.js',
631
output: {
732
path: `${__dirname}/dist`,
@@ -12,22 +37,36 @@ const config = {
1237
},
1338
module: {
1439
rules: [
40+
{
41+
enforce: 'pre',
42+
test: /\.(js)$/,
43+
exclude: /node_modules/,
44+
loader: 'eslint-loader',
45+
},
1546
{
1647
test: /\.js$/,
17-
use: [
18-
{
19-
loader: 'babel-loader',
20-
options: {
21-
presets: [
22-
['env', {'modules': false}]
48+
exclude: /node_modules/,
49+
use: {
50+
loader: 'babel-loader',
51+
options: {
52+
presets: [
53+
[
54+
'@babel/preset-env',
55+
{
56+
modules: false
57+
}
2358
]
24-
}
59+
],
60+
plugins: babelPlugin
2561
}
26-
],
27-
exclude: /node_modules/,
62+
}
2863
}
2964
]
30-
}
65+
},
66+
plugins: [
67+
webpackPlugEnv,
68+
webpackPlugBnr
69+
]
3170
};
3271

3372
module.exports = config;

0 commit comments

Comments
 (0)