Skip to content

Commit 163fdc9

Browse files
author
Lionel Bijaoui
committed
Update to Webpack 3. Almost all dependency are updated. Reorganisation of the config files. Now use Prettier, so most files are will need to be updated to validate. This is stil an early WIP.
Known bugs: validation is broken since rewritten in without "module.exports"
1 parent 244abb9 commit 163fdc9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+14712
-13985
lines changed

.babelrc

+31-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
{
2-
"presets": ["es2015", "stage-2"],
3-
"plugins": ["transform-runtime", "lodash"],
4-
"comments": false
5-
}
2+
"presets": [
3+
[
4+
"env",
5+
{
6+
"modules": false,
7+
"targets": {
8+
"browsers": ["last 2 versions"]
9+
}
10+
}
11+
],
12+
"stage-2"
13+
],
14+
"plugins": ["transform-runtime", "lodash"],
15+
"env": {
16+
"test": {
17+
"presets": [
18+
[
19+
"env",
20+
{
21+
"modules": false,
22+
"targets": {
23+
"browsers": ["last 2 versions"]
24+
}
25+
}
26+
],
27+
"stage-2"
28+
],
29+
"plugins": ["transform-runtime", "lodash"]
30+
}
31+
}
32+
}

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/*.js
2+
build/*.js
3+
config/*.js
4+
!.eslintrc.js

.eslintrc.js

+28-44
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,29 @@
11
module.exports = {
2-
root: true,
3-
"env": {
4-
"browser": true,
5-
"commonjs": true,
6-
"es6": true,
7-
"jquery": false,
8-
"mocha": true
9-
},
10-
"extends": "eslint:recommended",
11-
"parserOptions": {
12-
"sourceType": "module",
13-
"ecmaVersion": 6,
14-
"ecmaFeatures": {
15-
"experimentalObjectRestSpread": true
16-
}
17-
},
18-
"plugins": [
19-
"html"
20-
],
21-
"rules": {
22-
"indent": [
23-
"warn",
24-
"tab",
25-
{ SwitchCase: 1 }
26-
],
27-
"quotes": [
28-
"warn",
29-
"double"
30-
],
31-
"semi": [
32-
"error",
33-
"always"
34-
],
35-
"no-var": [
36-
"error"
37-
],
38-
"no-console": [
39-
"off"
40-
],
41-
"no-unused-vars": [
42-
"warn"
43-
]
44-
}
45-
};
2+
root: true,
3+
parser: "babel-eslint",
4+
parserOptions: {
5+
sourceType: "module"
6+
},
7+
env: {
8+
browser: true,
9+
commonjs: true
10+
},
11+
globals: {
12+
process: true
13+
},
14+
extends: ["eslint:recommended", "prettier"],
15+
plugins: ["html", "prettier"],
16+
rules: {
17+
indent: ["warn", "tab", { SwitchCase: 1 }],
18+
quotes: ["warn", "double"],
19+
semi: ["error", "always"],
20+
"no-var": ["error"],
21+
"no-console": ["off"],
22+
"no-unused-vars": ["warn"],
23+
// TODO reactivate after stabilisation
24+
"no-throw-literal": 0,
25+
eqeqeq: [0, "smart"],
26+
"spaced-comment": 0,
27+
"prettier/prettier": 0
28+
}
29+
};

.prettierrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"printWidth": 180,
3+
"tabWidth": 4,
4+
"singleQuote": false,
5+
"trailingComma": "none",
6+
"bracketSpacing": true,
7+
"semi": true,
8+
"useTabs": true
9+
}

build/utils.js

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
let path = require("path");
2+
let config = require("../config");
3+
let ExtractTextPlugin = require("extract-text-webpack-plugin");
4+
5+
exports.assetsPath = function(_path) {
6+
let assetsSubDirectory = process.env.NODE_ENV === "production" ? config.build.assetsSubDirectory : config.dev.assetsSubDirectory;
7+
return path.posix.join(assetsSubDirectory, _path);
8+
};
9+
10+
exports.cssLoaders = function(options) {
11+
options = options || {};
12+
13+
let cssLoader = {
14+
loader: "css-loader",
15+
options: {
16+
minimize: process.env.NODE_ENV === "production",
17+
sourceMap: options.sourceMap
18+
}
19+
};
20+
21+
// generate loader string to be used with extract text plugin
22+
function generateLoaders(loader, loaderOptions) {
23+
let loaders = [cssLoader];
24+
if (loader) {
25+
loaders.push({
26+
loader: loader + "-loader",
27+
options: Object.assign({}, loaderOptions, {
28+
sourceMap: options.sourceMap
29+
})
30+
});
31+
}
32+
33+
// Extract CSS when that option is specified
34+
// (which is the case during production build)
35+
if (options.extract) {
36+
return ExtractTextPlugin.extract({
37+
use: loaders,
38+
fallback: "vue-style-loader"
39+
});
40+
} else {
41+
return ["vue-style-loader"].concat(loaders);
42+
}
43+
}
44+
45+
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
46+
return {
47+
css: generateLoaders(),
48+
postcss: generateLoaders(),
49+
less: generateLoaders("less"),
50+
sass: generateLoaders("sass", { indentedSyntax: true }),
51+
scss: generateLoaders("sass"),
52+
stylus: generateLoaders("stylus"),
53+
styl: generateLoaders("stylus")
54+
};
55+
};
56+
57+
// Generate loaders for standalone style files (outside of .vue)
58+
exports.styleLoaders = function(options) {
59+
let output = [];
60+
let loaders = exports.cssLoaders(options);
61+
for (let extension in loaders) {
62+
let loader = loaders[extension];
63+
output.push({
64+
test: new RegExp("\\." + extension + "$"),
65+
use: loader
66+
});
67+
}
68+
return output;
69+
};

build/vue-loader.conf.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
let utils = require("./utils");
2+
let config = require("../config");
3+
let isProduction = process.env.NODE_ENV === "production";
4+
5+
module.exports = {
6+
esModule: false,
7+
loaders: utils.cssLoaders({
8+
sourceMap: isProduction ? config.build.productionSourceMap : config.dev.cssSourceMap,
9+
extract: isProduction
10+
})
11+
};

webpack.build.config.js build/webpack.build.config.js

+17-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
var webpack = require("webpack");
2-
var version = require("./package.json").version;
3-
var banner = "/**\n" + " * vue-form-generator v" + version + "\n" + " * https://github.com/icebob/vue-form-generator\n" + " * Released under the MIT License.\n" + " */\n";
4-
var ExtractTextPlugin = require("extract-text-webpack-plugin");
5-
var StatsPlugin = require("stats-webpack-plugin");
1+
let webpack = require("webpack");
2+
let version = require("./package.json").version;
3+
let banner = "/**\n" + " * vue-form-generator v" + version + "\n" + " * https://github.com/icebob/vue-form-generator\n" + " * Released under the MIT License.\n" + " */\n";
4+
let ExtractTextPlugin = require("extract-text-webpack-plugin");
5+
let StatsPlugin = require("stats-webpack-plugin");
66

7-
var loaders = [
7+
let rules = [
88
{
9-
"test": /\.js?$/,
10-
"exclude": /node_modules/,
11-
"loader": "babel"
9+
test: /\.js?$/,
10+
exclude: /node_modules/,
11+
use: "babel-loader"
1212
},
1313
{
14-
"test": /\.vue?$/,
15-
"loader": "vue"
14+
test: /\.vue?$/,
15+
loader: "vue-loader"
1616
}
1717
];
18-
var cssFileName;
18+
let cssFileName;
1919
if (process.env.FULL_BUNDLE !== "false") {
2020
cssFileName = "vfg.css";
2121
} else {
@@ -34,8 +34,8 @@ module.exports = [
3434

3535
plugins: [
3636
new webpack.DefinePlugin({
37-
"process.env" : {
38-
NODE_ENV : JSON.stringify("production")
37+
"process.env": {
38+
NODE_ENV: JSON.stringify("production")
3939
}
4040
}),
4141
new webpack.optimize.UglifyJsPlugin({
@@ -55,20 +55,19 @@ module.exports = [
5555
],
5656

5757
module: {
58-
loaders
58+
rules
5959
},
6060

6161
vue: {
6262
loaders: {
6363
css: ExtractTextPlugin.extract("css"),
6464
postcss: ExtractTextPlugin.extract("css"),
65-
sass: ExtractTextPlugin.extract("css!sass"),
65+
sass: ExtractTextPlugin.extract("css!sass")
6666
}
6767
},
6868

6969
resolve: {
7070
packageAlias: "browser"
7171
}
7272
}
73-
74-
];
73+
];

build/webpack.dev.config.js

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
const path = require("path");
2+
const webpack = require("webpack");
3+
const projectRoot = path.resolve(__dirname, "../");
4+
const vueLoaderConfig = require("./vue-loader.conf");
5+
const config = require("../config");
6+
7+
let rules = [
8+
{
9+
test: /\.(js|vue)$/,
10+
loader: "eslint-loader",
11+
enforce: "pre",
12+
include: [path.resolve("src")],
13+
options: {
14+
formatter: require("eslint-friendly-formatter")
15+
}
16+
},
17+
{
18+
test: /\.vue$/,
19+
loader: "vue-loader",
20+
options: vueLoaderConfig
21+
},
22+
{
23+
test: /\.js$/,
24+
loader: "babel-loader",
25+
include: projectRoot,
26+
exclude: /node_modules/
27+
},
28+
{
29+
test: /\.(woff2?|svg)$/,
30+
loader: "url-loader"
31+
},
32+
{
33+
test: /\.(ttf|eot)$/,
34+
loader: "url-loader"
35+
}
36+
];
37+
38+
module.exports = {
39+
devtool: "source-map",
40+
devServer: {
41+
contentBase: [path.resolve("dev/projects")]
42+
},
43+
entry: {
44+
full: path.resolve("dev", "projects", "full", "main.js"),
45+
basic: path.resolve("dev", "projects", "basic", "main.js"),
46+
mselect: path.resolve("dev", "projects", "multiselect", "main.js"),
47+
grouping: path.resolve("dev", "projects", "grouping", "main.js"),
48+
checklist: path.resolve("dev", "projects", "checklist", "main.js"),
49+
picker: path.resolve("dev", "projects", "picker", "main.js")
50+
},
51+
52+
output: {
53+
path: path.resolve("dev/projects"),
54+
filename: "[name].js",
55+
publicPath: "/"
56+
},
57+
58+
plugins: [
59+
new webpack.DefinePlugin({
60+
"process.env": {
61+
NODE_ENV: JSON.stringify("development"),
62+
FULL_BUNDLE: true
63+
}
64+
})
65+
],
66+
67+
module: {
68+
rules
69+
},
70+
71+
resolve: {
72+
extensions: [".js", ".vue", ".json"],
73+
alias: {
74+
vue$: "vue/dist/vue.esm.js",
75+
"@": path.resolve("src")
76+
}
77+
}
78+
};

config/index.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// see http://vuejs-templates.github.io/webpack for documentation.
2+
let path = require("path");
3+
4+
module.exports = {
5+
build: {
6+
env: { NODE_ENV: "\"production\"" },
7+
index: path.resolve(__dirname, "../../api/src/Template/Layout/layout_a.ctp"),
8+
assetsRoot: path.resolve(__dirname, "../../api/webroot/"),
9+
assetsSubDirectory: "layout_a",
10+
assetsPublicPath: "/",
11+
productionSourceMap: false,
12+
// Gzip off by default as many popular static hosts such as
13+
// Surge or Netlify already gzip all static assets for you.
14+
// Before setting to `true`, make sure to:
15+
// npm install --save-dev compression-webpack-plugin
16+
productionGzip: false,
17+
productionGzipExtensions: ["js", "css"],
18+
// Run the build command with an extra argument to
19+
// View the bundle analyzer report after build finishes:
20+
// `npm run build --report`
21+
// Set to `true` or `false` to always turn it on or off
22+
bundleAnalyzerReport: process.env.npm_config_report
23+
},
24+
dev: {
25+
env: { NODE_ENV: "\"development\"" },
26+
port: 8080,
27+
proxyTable: {},
28+
// CSS Sourcemaps off by default because relative paths are "buggy"
29+
// with this option, according to the CSS-Loader README
30+
// (https://github.com/webpack/css-loader#sourcemaps)
31+
// In our experience, they generally work as expected,
32+
// just be aware of this issue when enabling this option.
33+
cssSourceMap: false
34+
}
35+
};

0 commit comments

Comments
 (0)