diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000..11cadc4 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,12 @@ +module.exports = function (api) { + // Cache the returned value forever and don't call this function again. + if (api) api.cache(true); + + return { + presets: [ + ['@babel/preset-env', { + 'loose': true, + }], + ] + }; +}; diff --git a/example-vanilla/component.html b/example-vanilla/component.html new file mode 100644 index 0000000..bf6a64f --- /dev/null +++ b/example-vanilla/component.html @@ -0,0 +1,27 @@ + + +
+ HTML + + hello world + +
+ + \ No newline at end of file diff --git a/example-vanilla/index.js b/example-vanilla/index.js new file mode 100644 index 0000000..603514d --- /dev/null +++ b/example-vanilla/index.js @@ -0,0 +1,6 @@ +import createComponent from './component.html'; + +document + .body + .appendChild(document.createElement('div')) + .appendChild(createComponent()); \ No newline at end of file diff --git a/example-vanilla/webpack.config.js b/example-vanilla/webpack.config.js new file mode 100644 index 0000000..ac7732e --- /dev/null +++ b/example-vanilla/webpack.config.js @@ -0,0 +1,37 @@ +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const path = require('path'); +const rmlLoader = require.resolve('..'); + +module.exports = { + context: __dirname, + devtool: 'source-map', + mode: 'development', + entry: './index.js', + output: { + path: path.join(__dirname, 'dist'), + filename: '[name].js', + }, + module: { + rules: [ + { + test: /\.html$/i, + loader: rmlLoader, + options: { + renderer: 'vanilla', + inlineStyle: true, + }, + }, + { + test: /\.css$/, + use: require.resolve('stylesheet-loader'), + }, + ], + }, + plugins: [ + new HtmlWebpackPlugin(), + ], + devServer: { + hot: false, + inline: false, + }, +}; diff --git a/example/component.rml b/example/component.rml index 3711f43..413b1cd 100644 --- a/example/component.rml +++ b/example/component.rml @@ -76,11 +76,11 @@ 计算 - {/* */} +